Monday, March 10, 2008

JavaScript - View the current HTML state of your page

When you do View Source in your browser, it displays the state of your page when the
page is loaded. However, when you have dynamic content in your page, especially in
AJAX environment, you might need to see the current source of your page.
Type the following into your address bar and press enter.
Internet Explorer
javascript:'<xmp>'+window.document.body.outerHTML+'</xmp>'
Firefox
javascript:'<xmp>'+document.getElementsByTagName('html')[0].innerHTML+'</xmp>'
Or you can combine these two into one JavaScript statement to make it cross-browser:
javascript:'<xmp>'+((document.all) ? window.document.body.outerHTML :
document.getElementsByTagName('html')[0].innerHTML)+'</xmp>'

No comments: