Alan
Alan

Reputation: 9471

Objective C - UIWebview to load only a certain part of the webpage?

I am working with a UIWebview, is there anyway I can just load just the body of a webpage instead of the entire webpage with my UIWebView (aka not load the header and footer)? This website is not mine. But looking at the HTML of this site, I only want to load to div id="mainContent" to /div Either by writing some objective c or javascript?

Thanks! Alan

Upvotes: 3

Views: 5801

Answers (1)

Dru Freeman
Dru Freeman

Reputation: 1826

With Web-Kit you can parse the incoming HTML and do whatever you like to it (within, legal rights to the site you are reading)

Once the data is loaded in you can then push the edited HTML to the WKView fairly easily.

If you have an outlet to the webView you can do: (For example a UIWebView in iOS)

[webView loadHTMLString:htmlString baseURL:nil];
[webView setNeedsDisplay];

Upvotes: 3

Related Questions