Home >Web Front-end >JS Tutorial >How to save data when closing the window in asp javascript_javascript skills

How to save data when closing the window in asp javascript_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:07:491241browse

How to save data when closing the window

---------------

Use onunload event to open the above file

quit.asp A file that saves data. The above file is used to detect whether the window is closed or refreshed.

IE5 is compatible. In the past, window.opener.closed was used to determine, but IE5 does not support the closed attribute.
The above code has been tested many times and no problems have been found for the time being <script> <BR>  function IfWindowClosed() <BR>  {   <BR>    var win = null; <BR>    try <BR>    { <BR>      window.opener.name = "ss"; <BR>      if ( window.opener.name != "ss" ) <BR>      { <BR>        win = window.open("quit.asp","","width=100,height=100,left=10000,top=10000"); <BR>        window.setTimeout("window.close();",0); <BR>      } <BR>      window.opener.name = ""; <BR>    } <BR>    catch(e) <BR>    { <BR>      win = window.open("quit.asp","","width=100,height=100,left=10000,top=10000"); <BR>      window.setTimeout("window.close();",0); <BR>    } <BR>  } <BR>   <BR>  window.setInterval("IfWindowClosed()",100); <BR>  window.setTimeout("window.close();",510); <BR></script>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn