开发者

How to create <html>, <head> and <body> if they don't exist in an HTML?

When I load an HTML in a WebView, and the HTML has explicit <head> and <body>, I can get the head and insert a link to inject some CSS styles to the document on the fly.

I also manipulate the DO开发者_StackOverflow社区M on the body.

But what do I do when the HTML doesn't have this tags defined?

I can't modify the HTML file as it's user-provided.

I tried [DOMDocument createElement:] and [DOMDocument appendChild:] to insert a html, a head and a body, but didn't work.

How should this be done?


You could read the contents of the DOMDocument into an NSMutableString and append it then before loading the web view from this string...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜