How to save data when closing the window <SCRIPT language = "javascript">
Function IfWindowClosed ()
{
Var win = null;
Try
{
Window. opener. name = "ss ";
If (window. opener. name! = "Ss ")
{
Win = window. open ("quit. asp", "", "width = 100, height = 100, left = 10000, top = 10000 ");
Window. setTimeout ("window. close ();", 0 );
}
Window. opener. name = "";
}
Catch (e)
{
Win = window. open ("quit. asp", "", "width = 100, height = 100, left = 10000, top = 10000 ");
Window. setTimeout ("window. close ();", 0 );
}
}
Window. setInterval ("IfWindowClosed ()", 100 );
Window. setTimeout ("window. close ();", 510 );
</SCRIPT>
---------------
Use the onunload Event to open the above File
Quit. asp is the data storage file. The above file is used to check whether the window is closed or refreshed.
Ie5 is compatible. It was previously determined by window. opener. closed. ie5 does not support the closed attribute.
The above code has been tested many times and no problem is found for the time being.