Get the whole document's html with JavaScript/JQuery
This will get you all the HTML:
document.documentElement.outerHTML
Unfortunately it does not return the doctype. But you can use document.doctype
to get it and glue the two together.
You can do
new XMLSerializer().serializeToString(document);
for all browsers newer than IE 9
try this.
$("html").html()
document is a variable it dose not represent the html tag.
EDIT
To get the doctype one could use
document.doctype