I used $(document).html(), but that threw an error... is there a way to get everything?
+4
A:
You could try:
$("html").html();
If you want to also capture the hmtl tags you could concatenate them to the html like this:
function getPageHTML() {
return "<html>" + $("html").html() + "</html>";
}
Jimmie R. Houts
2009-06-11 18:12:33
Thanks!! That worked perfectly!!
Justin Lee
2009-06-11 19:10:57
A:
$("html").html()
would get everything but the outer most html tags.
Max Schmeling
2009-06-11 18:12:40
+6
A:
Don't forget the <html>
tag can have attributes too. If you want the whole document this should work.
var getEverything = function () {
var htmlStartTag = function () {
var attrs = $('html')[0].attributes;
var result = '<html';
$.each(attrs, function() {
result += ' ' + this.name + '="' + this.value + '"';
});
result += '>';
return result;
}
return htmlStartTag() + $('html').html() + '</html>';
}
Patrick McElhaney
2009-06-11 19:15:59