closed 属性可返回一个布尔值,该值声明了窗口是否已经关闭。该属性为只读。
当浏览器窗口关闭时,表示该窗口的 Windows 对象并不会消失,它将继续存在,不过它的 closed 属性将设置为 true。
window.closed
下面的例子可检测新窗口是否已被关闭:
<html> <head> <script type="text/javascript"> function ifClosed() { document.write("'myWindow' has been closed!") } function ifNotClosed() { document.write("'myWindow' has not been closed!") } function checkWin() { if (myWindow.closed) ifClosed() else ifNotClosed() } </script> </head> <body> <script type="text/javascript"> myWindow=window.open('','','width=200,height=100') myWindow.document.write("This is 'myWindow'") </script> <input type="button" value="Has 'myWindow' been closed?" onclick="checkWin()"> </body> </html>
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛
Powered by 365建站网 RSS地图 HTML地图
copyright © 2013-2024 版权所有 鄂ICP备17013400号