Created
October 26, 2010 06:40
-
-
Save arrix/646435 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getHTMLSource() { | |
var doc = document; | |
var dt = document.doctype; | |
var dtSource = ""; | |
if (dt) { | |
dtSource = '<!DOCTYPE html PUBLIC'; | |
if (dt.publicId) dtSource += (' "' + dt.publicId + '"'); | |
if (dt.systemId) dtSource += (' "' + dt.systemId + '"'); | |
dtSource += '>'; | |
} | |
var docSource; | |
var de = doc.documentElement; | |
if (de.outerHTML){ | |
docSource = de.outerHTML; | |
} else if (XMLSerializer) { | |
docSource = new XMLSerializer().serializeToString(de); | |
} else{ | |
docSource = '<html>' + document.innerHTML + '</html>'; | |
} | |
return dtSource + docSource; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment