Say the javascript has done some DOM manipulation like document.getElementById('id').innerHTML = "text"
. How do I get the frozen HTML at the very moment?
UPDATE:
I do not mean the particular code above. I mean after any sequence of operation.
Say the javascript has done some DOM manipulation like document.getElementById('id').innerHTML = "text"
. How do I get the frozen HTML at the very moment?
UPDATE:
I do not mean the particular code above. I mean after any sequence of operation.
Store it beforehand?
var currentHtml = document.getElementById('id').innerHtml;
document.getElementById('id').innerHtml = 'newHtml';
// codes
document.getElementById('id').innerHtml = currentHtml;
See this answer you can get the idea how to restore the original state:
How can I "reset" <div> to its original state after it has been modified by JavaScript?
An element's innerHTML property represents the markup that would generate its content at the moment it's read. However, it may not accurately represent attributes like listeners that have been dynamically added or altered.
If you wish to restore a fragment to its current state, you could clone and store it, then replace it as required. Again, listeners may or may not be accurately cloned depending on how they were added and the browser in use.
Why do you need the HTML? If you want it for debugging, you can use the Developer Tools in IE 9 by pressing F12. It usually shows the latest snapshot of HTML DOM.