Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove divs from UIWebView

Is it possible to remove a html div in objective-C/xCode? So for example the html looks like this :

<html>
  <div id="menu"> the menu code </div>
  <p> lorem ipsum text </p>
</html>

So if I could remove this menu only the text content would be displayed. That is what I want to make.

like image 819
Shishi Avatar asked Mar 20 '23 18:03

Shishi


1 Answers

You can use javascript to hide it in the webView delegate method:

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    NSString* script = [NSString stringWithFormat:@"document.getElementById(\"menu\").style.display='none';"];
    [self.webView stringByEvaluatingJavaScriptFromString:script];
}
like image 110
bsarr007 Avatar answered Apr 06 '23 06:04

bsarr007