umpirsky
umpirsky

Reputation: 10024

Get Entire Page Source in Firefox Addon

I'm trying to get page source together with doctype, head and body.

window.content.document is document but I can't collect anything except innerHTML which does not include doctype.

Upvotes: 0

Views: 330

Answers (1)

Wladimir Palant
Wladimir Palant

Reputation: 57691

DOCTYPE isn't included because it isn't a child of the document element, it's rather a direct child of the document itself. You can serialize the entire document using XML serializer however:

var serializer = new XMLSerializer();
alert(serializer.serializeToString(window.content.document));

This will do an XML serialization - not quite the same thing as HTML. If that's a problem you can go through the window.content.document.childNodes collection and get node.innerHTML for the element nodes (node.nodeType == 1), only use XMLSerializer on the rest of them. See https://developer.mozilla.org/en/XMLSerializer for more info.

Upvotes: 1

Related Questions