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

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -