How I can get the plain-text source of a web page that I've generated dynamically?

I want to know how I can get the plain-text source code of a web page that I’ve generated dynamically with JavaScript.


  1. 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.

  2. Javascript pass value to asp.net
  3. Html/Javascript: Add Attribute to an HTML Control
  4. set/get dynamically custom attribute
  5. Moving Object in a specified path in a browser through scrolling up/down.
  6. Dynamically update number of FuelUX wizard steps
  7. Dynamic Parameters for metaprogramming in JavaScript?
  8. 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.


I’d like to be able to see a plain text HTML representation of the page including content generated after page load with JavaScript.

  • How to access dynamic local variables
  • how to load google client.js dynamically
  • change form action target without javascript
  • Dynamic Parameters for metaprogramming in JavaScript?
  • Why can't I add rows dynamically to my HTML table?
  • How to dynamically change an image using javascript/jquery?
  • 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.

    While 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.