How I can get the plain-text source of a web page that I've generated dynamically?
I’m looking for a solution that allows me to see the updated html structure of my page’s as it appears when viewing the page’s original source code.
- set/get dynamically custom attribute
- Moving Object in a specified path in a browser through scrolling up/down.
- Dynamically update number of FuelUX wizard steps
I know that I can go into dev tools and look at the page’s current html structure in detail, but that is a mess to weave through, having to open each and every div on the page.
One Solution collect form web for “How I can get the plain-text source of a web page that I've generated dynamically?”
You can use outerHTML on the document element:
document.documentElement.outerHTML; // entire source
This will give you a snapshot of the HTML source at the moment of the call. If you call it after the dynamic content is added you’ll get the updated content.
outerHTML is not a part of the DOM specification, de-facto all browsers support it
Update, I double checked, outerHTML is now a part of the living standard here. Moreover, it is supported in all browsers.