I am developing a firefox extension and ideally would be able to get the whole darn DOM as a string.. forget any data structure. I just want what I see in "view source" in a buffer. I have been checking out javascri开发者_如何学编程pt references and HTMLDocument etc. with no avail.
Ideally I would be able to write to this buffer as well (seems possible i.e. document.writeLn()) I wish there was a document.read()? Am I just a js noob?
document.body.innerHTML
This should work
Maybe you want to traverse all the nodes of the DOM? You can do this with document.childNodes, working recursively with each node.
How about document.body.innerHTML? If you need the head contents as well, you can also try document.getElementsByTagName('head')[0].innerHTML and append the two.
Not sure if you can load jQuery from a FF extension but -
This came up just the other day as a jQuery question. You can use the jQuery selector $('*').html() to get all the html without the 'html' tags.
加载中,请稍侯......
精彩评论