0

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?

phabtar
  • 1,099
  • 1
  • 10
  • 16

2 Answers2

0

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
André Snede
  • 9,491
  • 6
  • 45
  • 64
0

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 :)

Community
  • 1
  • 1
dreamweiver
  • 5,964
  • 2
  • 26
  • 39