> JavaScript中文手册 > closed

定义和用法

closed 属性可返回一个布尔值,该值声明了窗口是否已经关闭。

语法

window.closed

浏览器支持

closedclosedclosedclosedclosed

所有主要浏览器都支持 closed 属性

实例

实例

检测新窗口"myWindow" 是否已被关闭:

function checkWin()
{
if (!myWindow)
  {
  document.getElementById("msg").innerHTML="'myWindow' has never been opened!";
  }
  else
  {
  if (myWindow.closed)
    {
    document.getElementById("msg").innerHTML="'myWindow' has been closed!";
    }
  else
    {
    document.getElementById("msg").innerHTML="'myWindow' has not been closed!";
    }
  }
}
运行一下 »
下一篇: