ios - How do I edit the HTML in a UIWebView? -


i have uiwebview loads html. how access html elements , change them?

i want like: webview.gethtmlelement(id: main-title).value = "new title"

if want edit in form, how can it:

- (void)webviewdidfinishload:(uiwebview *)webview {    nsstring *evaluate = [nsstring stringwithformat:@"document.form1.main-title.value='%@';", @"new title"];    [webview stringbyevaluatingjavascriptfromstring:evaluate]; } 

or if not in form, maybe (untested):

- (void)webviewdidfinishload:(uiwebview *)webview {    nsstring *evaluate = [nsstring stringwithformat:@"document.getelementbyid('main-title').value='%@';", @"new title"];    [webview stringbyevaluatingjavascriptfromstring:evaluate]; } 

note! assume editable field want change. otherwise talking parsing , concept works this:

    static bool firstload = yes;      - (void)webviewdidfinishload:(uiwebview *)webview {         if (firstload) {             firstload = no;             nsstring *html = [_webview stringbyevaluatingjavascriptfromstring:@"document.documentelement.outerhtml"];             //edit html here, parsing or similar.             [webview loadhtmlstring:html baseurl:[[nsbundle mainbundle] resourceurl]];         }     } 

you can read more parsing here: objective-c html parser


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -