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?
Asked
Active
Viewed 659 times
2 Answers
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
-
Author was asking the functionality in raw javascript. – dreamweiver Jul 15 '13 at 11:01
-
And I supplied an alternative, though your answer is probably more fitting. Either way, it still might help him. – André Snede Jul 15 '13 at 11:02
-
:) actually speaking the jQuery approach is what i feel the best, anyway you cant use jQuery lib if its of no use. – dreamweiver Jul 15 '13 at 11:14
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