When generating parts of the page dynamically using JavaScript it is handy to see the HTML code that your script is actually generating.
IE8 comes with View Generated Source context menu but it is a bit wonky. I had very little luck using it - it would show up in the but not on the pages that I want to see generated code for... There is a plugin for Firefox but it only works in Firefox.
Fortunately there is JavaScript solution to that.
This code will work in IE only:
window.open("javascript:'<xmp>' + opener.window.document.documentElement.outerHTML + '</xmp>'");
And this should work in any browser:
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 View Generated Source')
};
Save one of the two JavaScript bookmarklets on yout browser toolbar:
Bookmarklet for Internet Explorer - '+opener.window.document.documentElement.outerHTML+''"));">View Generated Source
Bookmarklet for any browser - '+window.document.body.outerHTML+''}%20else%20if%20(document.getElementsByTagName("html")[0].innerHTML%20!=%20undefined){''+document.getElementsByTagName("html")[0].innerHTML+''}%20else%20if%20(window.document.documentElement.outerHTML%20!=%20undefined){''+window.document.documentElement.outerHTML+''}%20else%20{%20alert('Your%20browser%20does%20not%20support%20View%20Generates')%20};">View Generated Source
Original idea - post on Ajaxian.com