Retrieving HTML from Dynamic Pages
Thursday, August 28th, 2008When testing dynamically generated web pages for accessibility, it can be difficult to get to the HTML source code that is the end result being rendered by the browser. Often choosing the browser’s View Source code option presents a lot of JavaScript calls and so forth that does not immediately make apparent what is actually being rendered to the screen.
One method to get at the source code that is worth a try, especially for pages that do not use frames, is to enter some JavaScript into the browser’s address bar to get an immediate action, similar to a development tool’s Immediate window.
This line will copy the HTML that is between the <Body> and </body> tags of the open webpage to the clipboard:
Javascript:window.clipboardData.setData(’text’, document.body.innerHTML);
Press Enter to execute this line after typing or copying it into the address bar.
In Internet Explorer 7 you may be presented with a warning message that the script is wanting to access the clipboard, you will need to allow it if you wish the HTML to be copied.
Then paste the contents of the clipboard into a text editor and view it.
Variations of the above DOM reference (document.body.innerHTML) should retrieve specific portions of the page if you would like to more specifically pinpoint an area.