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,139
  • 1
  • 11
  • 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,899
  • 7
  • 43
  • 67
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
  • 6,002
  • 2
  • 24
  • 39