Can I capture and save the current state of a webpage using javascript

ajax, dom, javascript

Solution

Try the following code:

var body = document.getElementsByTagName("body");
var bodycontent = body[0];

Then use "bodycontent.innerHTML" to retrieve the contents of it. If I'm not mistaken, it should provide the body's current content, after any javascript modifications that have been made to it.

Problem

I need to get the entire contents of a page with javascript and send it to a server script to save it. I want to do this after the user has made some changes to the page using AJAX and other javascript tools. I don't want the state of certain elements. I'd like to essentially get everything inside the body tag so I can pass it to a server-side script. I have tried getelementbyid etc. but it seems to put the page in a loop and crashes. Thanks

Original source

Related problems