How to View Page Source Including Dynamic Script and Elements

By Peter Bromberg

This is a little-known browser trick that enables you to view the source of a page including all dynamically created script and elements, which the normal browser View Page Source command does not do.


Create a new Favorite (or Bookmark) in your browser. I named mine "DebugJS".  As the target URL of the favorite, enter the following statement:


javascript:document.write(%22%3Cxmp%3E%22+document.documentElement.innerHTML+%20%22%3C/xmp%3E%22);


Save the Favorite or Bookmark. You may receive a warning prompt. It is safe to dismiss this.

Now, when you are viewing any web page, by invoking this favorite you will see all the markup and script of the page - even dynamically generated script and DOM elements.

How to View Page Source Including Dynamic Script and Elements  (769 Views)