How to View Source HTML of Modal Dialog Window

Its a known functionality of the windows opened using ShowModalDialog function of javascript that you can not view html source of a modal dialog window but its a problem during the development because you might need to view html source of the window for debugging.
Here is the simple solution of the problem...

Add following javascript code in your web page.

< script language="javascript" >
function showHTML()
{
d=window.open();
d.document.open('text/plain').write(document.documentElement.outerHTML);
}
< /script >

And add following html code anywhere in the body of the web page.

< input type=button value="View Source" onclick="showHTML()" >

Now when you will browse your modal window and click on the said button, the HTML source code of the modal window will open in another window.

3 comments:

Anonymous said...

pervyy nax!

mikedanese said...

Thanks Sanjay,
I looked all over to see how to do it(show/view source of modal window).
Thanks for posting. MD.

Allan said...

we provide our valued clients a comprehensive portfolio of new age IT consulting services that streamline their process, help them manage change, innovate newer opportunities for maximizing profit and best of all assist build a credible brand.