Hello! Is there someway to get the HTML-code which represent the page at a current time? for example: <html> <head> <script type="text/javascript"> function load() { document.body.innerHTML += "Hello!" } </script> </head> <body onload="load()"> </body> </html> Code (markup): After the page has loaded the actual HTML-code really looks something like this: <html> <head> <script type="text/javascript"> function load() { document.body.innerHTML += "Hello!" } </script> </head> <body onload="load()"> Hello!</body> </html> Code (markup): But is there some way to extract that HTML-code from the document and not the one that was initially loaded (the second code and not the first of the two I wrote here)?
If you use window.document.documentElement.innerHTML - this should give you the current contents of the HTML document Or - did you just mean "How do I view the source code with the newly updated content, added in by Javascript?" If you're using Firefox, I've noticed a peculiarity with the "View source" functionality. If you select "View source" from the top menu bar, it won't show up any modifications (like "Hello!") that Javascript has made. But, if you select all the code on the page (do a right-click "select all") and then right-click "view selection source" this will show up the changes that Javascript has made.
Awsome! I'll just use document.documentElement.innerHTML. I'll check that "view selection source" in FF, seems weird, but anyway