简体   繁体   English

使用客户端JavaScript将HTML快照发送到服务器

[英]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.

相关问题 使用javascript将图像发送到数据库(客户端) - Send image to database using javascript (client side) 如何使用 JavaScript 将 HTML 表单数据通过电子邮件发送到电子邮件 ID,而不使用服务器端语言,而不使用电子邮件客户端安全? - How to send HTML form data by email to an email ID by using JavaScript, without using server-side language, without using email client securely? 在客户端获取快照大小 - Firestore javascript - Get snapshot size on client side - Firestore javascript 如何使用Ajax将客户端JavaScript变量发送到服务器 - How do you send a client side javascript variable to your server using ajax 如何使用客户端javascript向具有特定端口的服务器发送请求? - How to send a request using client-side javascript to a server with specific port? 如何使用客户端JavaScript将数据发送到Node.js服务器 - How to send data to a node.js server using client side javascript 客户端javascript或服务器端 - client side javascript or server side 如何将 javascript 文件(其中包含多个函数)从服务器发送到客户端? - How to send a javascript file (with several functions in it) from the server to the client side? 是否有可能在服务器端加密并在客户端解密(使用javascript)? - is it possible to encrypt at server side and decrypt it on the client side (using javascript)? Javascript:使用变量访问服务器端变量客户端 - Javascript: access server side variable client side using variable
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM