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.
Any ideas? Oh, and manual "parsing" is not an option.
精彩评论