[英]Send html snapshot to server using client side javascript
Is there a way to send the fully generated html code of its own web page using javascript. 有没有一种方法可以使用javascript发送自己网页的完全生成的html代码。 For example, at a button click event, the current html code of the page is sent back to the server.
例如,在按钮单击事件中,页面的当前html代码将发送回服务器。 How to do this?
这个怎么做?
Using jQuery, this should do that for you: 使用jQuery,这应该为您做到这一点:
$("html").html()
And if you really need the HTML tags: 如果您确实需要HTML标签:
function getPageHTML() {
return "<html>" + $("html").html() + "</html>";
}
Even: 甚至:
$('html')[0].outerHTML
you can access the source code this way 您可以通过这种方式访问源代码
document.documentElement.outerHTML/innerHTML
REF: How do I get the HTML source from the page? REF: 如何从页面获取HTML源代码?
Happy Coding :) 快乐编码:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.