Is it possible to capture the rendered HTML page from Javascript.
- I want to be able to create a "minimap" of an HTML page for quick navigation.
Is it possible to capture the rendered HTML page from Javascript.
You can use:
document.body.innerHTML
That is the whole "rendered" (ie. live/DOM-complete) HTML, but I'm not sure this is what you want.
You would be better defining what it is you want to create a map of, for example headings etc, then you can use getElementsByTagName('h1') (for example) to grab all of the H1's on the page.
If you're talking an actual image as rendered by a browser, you can take a look at wkhtmltopdf and it's wkhtmltoimage counterpart, which will take HTML (or a web address) as an input and convert it either to a text-complete PDF, or a static image. Have used this neat app before on large projects so it's definitely reliable, also uses WebKit so CSS3/JS compatible.