How can I read a HTML comment located outside of <html> using JavaScript?

dom, html, javascript

Solution

I did some testing on this and discovered that any HTML beyond `</html>` is appended to the `<body>` during parsing. So, in all browsers I tested (IE6/7, FF3, Opera10, Chrome2), the comment was accessible as `document.body.lastChild` and its contents can be retreived via `document.body.lastChild.data`.

Problem

I have a HTML comment outside of the DOM root node which I need to read: ``` <html> ... other stuff </html> <!-- The comment I want to read --> ``` Can I do this with JavaScript somehow?

Original source