關(guān)閉窗口時(shí)保存數(shù)據(jù)的方法
發(fā)表時(shí)間:2023-08-17 來源:明輝站整理相關(guān)軟件相關(guān)文章人氣:
[摘要]<SCRIPT language="javascript"> function IfWindowClosed() { var win = null...
<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>
---------------
用onunload事件打開上面的文件
quit.asp為保存數(shù)據(jù)的文件,上面的文件用來檢測(cè)窗口是關(guān)閉還是刷新
ie5兼容,以前使用 window.opener.closed來判斷,ie5不支持closed 屬性。
上面的代碼經(jīng)過多次測(cè)試,暫時(shí)沒有發(fā)現(xiàn)問題