代码示例:(标识:jsck_win_closed)
<!DOCTYPE html>
<html>
<body>

<h1>Window 对象</h1>

<h2>closed 属性</h2>

<p><button onclick="openWin()">打开 "myWindow"</button></p>
<p><button onclick="closeWin()">关闭 "myWindow"</button></p>
<p><button onclick="checkWin()">"myWindow" 被关闭了吗?</button></p>

<div id="demo"></div>

<script>
let myWindow;

function openWin() {
  myWindow = window.open("", "myWindow", "width=400,height=200");
}

function closeWin() {
  if (myWindow) {
    myWindow.close();
  }
}

function checkWin() {
let text = "";
if (!myWindow) {
  text = "它从未被打开过!";
} else {
  if (myWindow.closed) { 
    text = "它是关闭的。";
  } else {
    text = "它是打开的。";
  }
}
document.getElementById("demo").innerHTML = text;
}
</script>

</body>
</html>
运行结果: