我可以捕捉并使用JavaScript保存网页的当前状态 [英] Can I capture and save the current state of a webpage using javascript

查看:143
本文介绍了我可以捕捉并使用JavaScript保存网页的当前状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要得到一个网页的全部内容与JavaScript并将其发送到服务器脚本保存它。我想这样做后,在用户中取得使用AJAX和其他JavaScript工具,一些修改页面。我不希望某些元素的状态。我想从根本上得到的一切身体标记内,所以我可以将它传递到服务器端脚本。我已经试过的getElementById等,但似乎把页面在一个循环和崩溃。

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.

感谢

推荐答案

请尝试以下code:

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

然后使用bodycontent.innerHTML来检索它的内容。如果我没有记错的话,它应该提供人体的当前内容后,已给它的任何JavaScript修改。

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.

这篇关于我可以捕捉并使用JavaScript保存网页的当前状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆