Off-hand, one can think of at least two methods both with some limitation(s).
[tt]
function doit() {
if (window.ActiveXObject) {
var oxmlhttp=new ActiveXObject("Msxml2.xmlhttp");
} else if (window.XMLHttpRequest) {
var oxmlhttp=new XMLHttpRequest();
}
oxmlhttp.open("GET",window.location,false);
oxmlhttp.send(null);
var s=oxmlhttp.responseText;
oxmlhttp=null;
alert(s);
}
function doit2() {
var s="<head>\n"+document.getElementsByTagName("head")[0].innerHTML+"\n</head>\n";
s+="<body>\n"+document.body.innerHTML+"\n</body>\n";
alert(s);
}[/tt]
I do see the limitations of both but that will have to do, unless someone knows a better way that can grab the DOCTYPE and all that without reloading the page?
Maybe I don't?
The problem I see with function doit() is that it requires time to completely reload the page but you get a complete page, unless of course there is some session/cookie work that will keep the page from loading again, for instance if it was a purchase process and a confirmation page, hopefully it won't do another purchase...
on the other hand doit2() is not goint to get the:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "
DocType tag. ALSO, if the page is not well formed HTML there could be trouble, for instance a page with 2 body tags (some interstitial pages use this method) then it's going to take more work to get the HTML correct.
Are there other limitations besides these? or is there a way to get the DOCTYPE tag with doit2()?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.