Internet Explorer (all versions) appears to completely disregard any changes made to the DOM when you use the Save As command, reverting the saved version to the state of the webpage on first load. This affects javascript apps where you are trying to save a snapshot of the app's current state.
In this following trivial example, when you load the page, a random number appears. Saving this page in Firefox or Chrome results in that number being FIXED in the resulting saved document (because next time you open it, the .generateRandomNumber span has been deleted and overwritten, so the JS is not executed).
<!DOCTYPE HTML>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
jQuery(function($) {
if ($('.generateRandomNumber').length) {
var randomNumber = Math.round(Math.random() * 1000);
$('.generateRandomNumber').remove();
$('body').html(randomNumber);
}
});
</script>
</head>
<body>
<span class="generateRandomNumber"></span>
</body>
</html>
You can also see the behaviour by doing the following from the IE console:
var w = window.open();
w.document.body.innerHTML = "Hello world. Please save me";
Another simple example would be to run the following script to any page (from IE dev console). Run it, watch the HTML get wiped, save it, open the saved version and see the original site reappear.
document.body.innerHTML = "";
Save that new document, and the text will be gone when you next open it.
I've reviewed the following pages, but now found any solution:
Save the document generated by javascript
Any help would be much appreciated.