参数列表如下:
使用 window.closed 属性可以检测当前窗口是否关闭,如果关闭则返回 true,否则返回 false。
下面是一个监听当前新开页面该窗口的打开关闭状态的示例
参考: https://blog.csdn.net/HeXinT/article/details/125412106
function countDown(secs, surl) {//alert(surl)
var jumpTo = document.getElementById('jumpTo')
jumpTo.innerHTML = secs
if (--secs > 0) {
setTimeout("countDown(" + secs + ",'" + surl + "')", 1000)
}
else {
//兼容360,IE火狐的关闭窗口方法 > CHROME + Gecko + MS > 需要用户accept,除非通过用户的动作激发
window.open(surl, "_blank")
if (navigator.userAgent.indexOf("MSIE") > 0) {
if (navigator.userAgent.indexOf("MSIE 6.0") > 0) {
window.opener = null
window.close()
this.parent.window.close()
} else {
window.open('', '_top')
window.top.close()
this.parent.window.close()
}
} else if (navigator.userAgent.indexOf("Firefox") > 0) {
window.location = ''
window.top.close()
this.parent.window.location = surl
this.parent.window.top.close()
} else {
window.opener = null
window.open('', '_self')
window.close()
this.parent.window.close()
}
//window.open('', "_blank")
//window.close()
//this.parent.window.close()
}
}
这个需要用户进行操作才能够不会被拦截--会被当作恶意弹窗处理
做一个触摸屏查询系统,要打开新页面后关闭父界面 百度之functionopenNewWindow() { window.open("Index.aspx","","left=30,top=30,toolbar=no,menubar=no,scrollbars=no,resizable=no,status=no,location=no,directories=no,copyhistory=no,height=620,width=820")window.opener=nullwindow.open("","_self")window.close()}这样写的话,由于窗口拦截的原因,会使新窗口打不开,而且原来的窗口也被关闭了
于是再查询找到解决去方法在新页面中onload="window.opener。opener=nullwindow.opener.close()"