• Home
  • About
  • Resume

View real HTML source of a page

By , 11/06/2009 1:48 PM

All browsers support “View page source” feature. But what it displays is source of the page as it was originally rendered by the server. In today’s Web 2.0 world page content can change a thousand times after that. Client-side script, user input, AJAX calls can contribute to page update.

But one line of JavaScript code can show you a real up-to date page source. Type following in your browser address bar:

javascript:void prompt('HTML Source',document.documentElement.innerHTML)

You will see a JavaScript prompt, with text field prefilled with HTML source of the page.

Just copy it from there and paste it to where it can be put to a good use.

Note “void” in front of function call. It prevents browser from going to a new page, displaying “null” after the prompt is closed.

This approach works both i IE and Firefox, but if you use IE, you can use “.outerHTML” property to display full page source in its entirety from <HTML> to </HTML>.

Leave a Reply

Panorama Theme by Themocracy