I need to get the entire contents of a page with javascript and send it to a server script to save it. I want to do this after the user has made some changes to the page using AJAX and other javascript tools. I don't want the state of certain elements. I'd like to essentially get everything inside the body tag so I can pass it to a server-side script. I have tried getelementbyid etc. but it seems to put the page in a loop and crashes.
Thanks
Any web browser can quickly save the webpage that you are currently visiting. You will then be able to open this webpage at any time, even if you're offline. Press Ctrl + S (PC) or ⌘ Cmd + S (Mac). This opens the Save Page window in all major web browsers.
If for some odd reason, you wanted to view the source code of another page without having to actually browse to that page and click “page view source,” you can use JavaScript to do so. In the example below, I use the “window.
Android. Save a web page on the Android app by opening the three-dot menu icon and tapping the download icon up top. A banner at the bottom of the screen will tell you when the page has been made available for offline reading. Click Open to view a static version of the page.
Try the following code:
var body = document.getElementsByTagName("body");
var bodycontent = body[0];
Then use "bodycontent.innerHTML" to retrieve the contents of it. If I'm not mistaken, it should provide the body's current content, after any javascript modifications that have been made to it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With