开发者

UIWebView Deleting tags from html

开发者 https://www.devze.com 2023-03-17 03:12 出处:网络
For example I have returned html in UIWebView text: <div id=\"id1\"开发者_Go百科><p>Some Text</p></div>

For example I have returned html in UIWebView text:

<div id="id1"开发者_Go百科><p>Some Text</p></div>

<div id="id2"><p>SOME TEXT</p></div>

And I need to delete tag with id="id2", and return to user, how can I do this?


One solution is call js code which removes that element after content is loaded.

NSString *jsCommand = [NSString stringWithFormat:
         @"var element = document.getElementById('%@'); element.parentElement.removeChild(element);",
         @"id2",
];
[webView stringByEvaluatingJavaScriptFromString:jsCommand]
0

精彩评论

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