Saturday, July 22, 2006

Viewing Current HTML Source in AJAX

Now this is a solution I have been waiting for a long time. In AJAX based applications, everyone knows that it is possible to change the HTML without even refreshing the page. Here's the catch: Suppose you have done so, and now face an error. You want to debug the HTML, but now find that when you do a View Source, you get the HTML that was originally sent by the browser, not the current HTML. This can get increasingly frustrating, and sometimes even gets on your nerves. Why can't there be an option to view the current HTML? Many of the developers in my office resigned to this fact.

But fear not, frustrate not. You do have an option, a way out. In fact, two ways, if you are using Firefox/Mozilla apart from IE. If you are using Firefox/Mozilla, simply install the WebDeveloper extension. This is very useful for web developers like you and me. Apart from the various options it provides, click on the View Source -> View Generated Source menu option and hey presto!!, you get what you want.

OK, that one was for Firefox/Mozilla. What about IE? For that, you must visit this blog entry by Rumen Stankov.

Update (10th Jan 2008): Looks like the link to the Rumen Stankov article doesn't work. Well, I'll post the info here. In IE, to get the latest HTML source, just type

javascript:“<xmp>” + document.body.innerHTML + “</xmp>”
in the address bar and press Enter.

1 comment:

Ariel said...

Hi, did anyone achieve to get updated source code from vb.net webbrowser?