Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obtain current page's source using javascript and DOM [duplicate]

How do I obtain the current page's source using JavaScript and DOM? Would I have to use AJAX?

like image 402
swatkat Avatar asked Dec 05 '25 13:12

swatkat


1 Answers

The current page's source:

document.documentElement.outerHTML

Obviously, that is what the page looks like right now. In case of DHTML, if you want to get the unmodified source as it was served from the server, you will need to make an AJAX call to receive it again, and capture it there.

EDIT: was incorrectly innerHTML.

like image 153
Amadan Avatar answered Dec 08 '25 02:12

Amadan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!