Viewing dynamically generated HTML in a help topic

January 2nd, 2009

This is an old tip (see Viewing dynamic HTML in a .chm topic from March 2004) but worth knowing.

Suppose you have some JavaScript in a help topic that alters the HTML of the page - for example, it might do some transformations onLoad, or it might be doing AJAX-type stuff in response to input from the user). To debug the JavaScript you need to be able to check the HTML to make sure the transformations are occurring as designed. Right-clicking and choosing View Source is no good because you only see the original HTML saved in the file, before any transformations happened.

To see the dynamically generated HTML as it is right now:

  1. Copy the following:

    javascript:window.open("").document.open("text/plain", "").write(document.documentElement.outerHTML);

  2. Right-click the title bar of the HTML Help Viewer.
  3. Choose Jump to URL.

    jump-to-url

  4. In the Jump to URL dialog box, paste the text you copied in step 1.

    jump-to-url-dialog2 

    The HTML is displayed in a new Internet Explorer window.

Leave a comment