Is it possible to get the source of the current HTML document, exactly as it was loaded, in text form? (i.e. not the "Generated source" after parsing and DOM manipulation.)
Note: Issuing an extra AJAX request to retrieve the HTML page again is not an option in this case: The document could have changed.
Most browsers have a "view source" functionality, which would provide exactly what I want - so browsers keep the original HTML content anyway. Would be nice, if I could access that...
You can't do this with JavaScript, the browser has no responsibility to keep the original document really. Is making an AJAX request with a timestamp an option? You could store the loaded date of the page with new Date()
and pass this timestamp to the server when asking for the document again, if a history was available.
Other than that...I'm not sure how you'd do this with JavaScript/HTML. What is your actual end-game goal here though? Are you seeing if a <form>
and it's inputs changed, or something else?
As far as I know of, there is no way of doing so.
You may try grab the HTML very early and store it in a variable, but that's a very poor alternative because:
<script>document.write(stuff);</script>
you may already seeing a different view over the HTML content)Re-fetching the document with AJAX, despite its many possible implications, may be your best alternative regarding this matter.
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