简体   繁体   中英

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. For example, at a button click event, the current html code of the page is sent back to the server. How to do this?

Using jQuery, this should do that for you:

$("html").html()

And if you really need the HTML tags:

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?

Happy Coding :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM