关闭窗口时保存数据的办法
内容摘要
< SCRIPT language="javascript"> function IfWindowClosed() { var win = null; try { window.opener
文章正文
< 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为保存数据的文件,上面的文件用来检测窗口是关闭还是刷新
ie5兼容,以前使用 window.opener.closed来判断,ie5不支持closed 属性。
上面的代码经过多次测试,暂时没有发现问题
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为保存数据的文件,上面的文件用来检测窗口是关闭还是刷新
ie5兼容,以前使用 window.opener.closed来判断,ie5不支持closed 属性。
上面的代码经过多次测试,暂时没有发现问题
<script type="text/javascript">BAIDU_CLB_fillSlot("160927");</script>
代码注释