开发者

How to get a webpage's head without running contained scripts?

Say I want to extract the <head> of some HTML page on the same domain.

Easy: load the page into an iframe, put an onload handler on, then use myFrame.contentDocument.getElementsByTagName('head'). But: The page may contain scripts, which should not run, since that may take way too long in my situation.

For this purpose, HTML5 offers the sandbox attribute, which would do the trick, but I need to get things running in older browsers.

I've also tried to use XHR in combination with frame.documentElement.innerHTML, but this doesn't seem to work with the injected <head> portion in FF3.6.

开发者_JAVA百科

Any ideas? Oh, and manual "parsing" is not an option.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜