Thursday, February 23rd, 2006
IE Tip: Cheeky way to see the current state of the page
Who needs debuggers and add ons, when you can simply put the following in your IE address bar:
JAVASCRIPT:
-
-
javascript:'<xmp>'+window.document.body.outerHTML+'</xmp>';
-





3.8 rating from 84 votes








or for IE:
javascript:'<xmp>'+window.document.documentElement.outerHTML
+'</xmp>';
Or, push it to a new popup window so you don’t lose the page:
javascript:window.open(”javascript:” +opener.window.document.documentElement.outerHTML +””);
Oops, the previous comment should say:
javascript:void(window.open(”javascript:” + opener.window.document.documentElement.outerHTML + ””));
OK, hopefully the last time (HTML and quotes were being converted):
javascript:void(window.open("javascript:'<xmp>' + opener.window.document.documentElement.outerHTML + '</xmp>'"));
So simple yet so cool. Dunno why I never thought of this…
Thanks for the great tip!
It works in IE and Opera. The same bookmarklet for Firefox&co is here:
javascript:''+document.getElementsByTagName("html")[0].innerHTML+”;I mean
javascript:'<xmp>'+document.getElementsByTagName("html")[0].innerHTML+’</xmp>’;And just for giggles, here’s all three rolled into one!
javascript:if (window.document.body.outerHTML != undefined){”+window.document.body.outerHTML+”} else if (document.getElementsByTagName(”html”)[0].innerHTML != undefined){”+document.getElementsByTagName(”html”)[0].innerHTML+”} else if (window.document.documentElement.outerHTML != undefined){”+window.document.documentElement.outerHTML+”} else { alert(’Your browser does not support this method of viewing the page source.’) };
Sorry about the double post… forgot to escape the < and > when I posted. Duh… live preview further down on the page. Let me strap my helmet back on….
javascript:if (window.document.body.outerHTML != undefined){’<xmp>’+window.document.body.outerHTML+’</xmp>’} else if (document.getElementsByTagName(”html”)[0].innerHTML != undefined){’<xmp>’+document.getElementsByTagName(”html”)[0].innerHTML+’</xmp>’} else if (window.document.documentElement.outerHTML != undefined){’<xmp>’+window.document.documentElement.outerHTML+’</xmp>’} else { alert(’Your browser does not support this functionality’) };
Instead of using document.body.outerHTML, I would recommend using document.documentElement.outerHTML : That way, you will also get the root node of the document you’re checking.
Instead I just wiggle my fingers and websites do what I need them to do
[...] Found a interesting little post on Ajaxian, often in the SEO bussiness you want to fund the source code as fully rendered by the browsers. This is an easy method to do so, place this code in your address bar when viewing the page. javascript:’’+window.document.body.outerHTML+’’; [...]
Great tip. I vote for the last comment by James. At least that works best for me in IE…