Retrieving HTML from Dynamic Pages
When 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.
September 29th, 2008 at 5:39 pm
[...] The important thing to remember here is the end result of these JavaScript frameworks—whether it is Yahoo, Google, Dojo or other–is still to produce HTML, as browsers render HTML to the screen to create the visible content. I have included a sample of the HTML from the yahoo example at the bottom of this post. (For one method to get at the HTML of a client-side, dynamically generated page, look at the post “Retrieving HTML from dynamic pages.”) [...]