I know it\'s already discussed here, but there were no solution to get the whole document (including doctype).
$(document).html(); returns null
$(document).html();
null
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.
document.doctype