swmr
07-03-2003, 01:22 AM
Is there is some method for detecting whether any changes have occured within a document's innerHTML?
The only mention of this I've seen referred to "DOMSubtreeModified", but with no explanation of how to use it.
My purpose is to display a confirm message (for overwriting the document) if any styles, values, or content have been modified (or just close the document without a message, if nothing has changed).
Here is a crude/limited example of what I'm trying to accomplish:
<HTML XMLNS:HTA><HEAD><TITLE>docOverwite</TITLE><HTA:APPLICATION></HTA:APPLICATION>
<SCRIPT type=text/JScript>
window.onbeforeunload=function determine(){
if (Box.checked==true){return ask()}}
function ask(){
Box.checked=false;if (confirm("Overwrite this document?")){
return save()}else opener=self;opener.close()}
function save(){
var thisLocation=document.URL.replace(/^(file:\/\/)/,"").replace(/(\\)/g,"\\\\").replace(/(%20)/g," ");
var forWriting=2;
var dataFile=thisLocation;
var fso=new ActiveXObject("Scripting.FileSystemObject");
ts=fso.OpenTextFile(dataFile,forWriting,true);
ts.Write(document.documentElement.outerHTML);
ts.Close();
}
</SCRIPT>
</HEAD>
<BODY bgColor=buttonface>
<TEXTAREA style="WIDTH: 100%; HEIGHT: 200px" onpropertychange=Box.checked=true></TEXTAREA>
<INPUT id=Box disabled type=checkbox></BODY></HTML>
The only mention of this I've seen referred to "DOMSubtreeModified", but with no explanation of how to use it.
My purpose is to display a confirm message (for overwriting the document) if any styles, values, or content have been modified (or just close the document without a message, if nothing has changed).
Here is a crude/limited example of what I'm trying to accomplish:
<HTML XMLNS:HTA><HEAD><TITLE>docOverwite</TITLE><HTA:APPLICATION></HTA:APPLICATION>
<SCRIPT type=text/JScript>
window.onbeforeunload=function determine(){
if (Box.checked==true){return ask()}}
function ask(){
Box.checked=false;if (confirm("Overwrite this document?")){
return save()}else opener=self;opener.close()}
function save(){
var thisLocation=document.URL.replace(/^(file:\/\/)/,"").replace(/(\\)/g,"\\\\").replace(/(%20)/g," ");
var forWriting=2;
var dataFile=thisLocation;
var fso=new ActiveXObject("Scripting.FileSystemObject");
ts=fso.OpenTextFile(dataFile,forWriting,true);
ts.Write(document.documentElement.outerHTML);
ts.Close();
}
</SCRIPT>
</HEAD>
<BODY bgColor=buttonface>
<TEXTAREA style="WIDTH: 100%; HEIGHT: 200px" onpropertychange=Box.checked=true></TEXTAREA>
<INPUT id=Box disabled type=checkbox></BODY></HTML>