开发者

Can I access HTML DOM in other frame of other domain in UIWebView javascript injection?

I'm injecting some JavaScript code to get internal开发者_如何学Go DOM information of UIWebView. Currently, all of codes are irking well, but I met a big problem. The document in IFRAME of other domain. By cross-domain security policy, I can't access DOM of the IFRAME if the frame contains document which its address is different with current page. My UIWebView have to be able to process any sites on internet. Is there any way to evade this security policy?


With UIWebView? No.

The only way around this would be to parse the HTML yourself (I'd suggest a library - Element Parser is pretty good). You'd obviously have to look for IFRAME tags and load that content recursively.


IFrames in the document can be found in the javascript variables document.frames this is an array containing all the iframes. Through this you can access the DOM of the iframe via javascript.

Using javascript you can callout to your UIWebViewDelegate by making a special request and process the iframes content.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜