Have you ever wanted to see the dynamically generated HTML of a page? If you use AJAX or lot of Javascript, I am sure you have added HTML content to your page on the fly and you wanted to see the active HTML source of that page, since IE only shows the original HTML source.
Perhaps you already know about how to do this, but, I often use this little Javascript code snippet to see the active content of a page and it really comes handy while developing web pages that use lot of Javascript to dynamically add content:
javascript:window.open("").document.open("text/plain", "").write(document.documentElement.outerHTML);
I simply type this in the address bar and viola, I have the current HTML source of the page popped up in a new browser window. Better yet, I created a bookmark link using this snippet and every time I need to see the active HTML source of a page, I just click on this link.
Here are the steps to add a bookmark link for this Javascript snippet:
- In IE, press Ctrl+D to bring up "Add a Favorite" dialog
- Give it a name, something like "View Active Source"
- Use Links folder to create in and OK the dialog
- Have the Links toolbar displayed in your browser if it is not already
- Right-click on the "View Active Source" button > Properties
- In the "Web Document" tab, type the above line "javascript:..." in the URL box and OK the "View Active Source Properties" dialog
- Click "Yes" to the following warning message:
The protocol "javascript" does not have a registered program. Do you want to keep this target anyway? - Now, click on the button "View Active Source" in the Links toolbar and now you should be able to see the active HTML of the current page in a new window
- As my title indicates, I have only tested this in IE and do not know if it works in other browsers or not. On that thought, other browsers might already provide this functionality and I remember hearing from a friend that Firefox does
- It won't work if Popup Blocker is turned on
Hope you find this useful and if you know any other cool ways to see the active HTML content of the page, please let me know.
Thanks for visiting my blog.
Sonny
6 comments:
Works great!, but all the commands are Capiltal letters.
That was really helpful.
Glad to hear that folks finding it useful.
You write very well.
You're a lifesaver.
2012 and found this extremely useful in IE8 ('links' toolbar is now called 'favorites').
Amazing that IE does no show the active src - even in the F12 you have to hit its refresh button.
Post a Comment