closed

window.closed 窗口是否已关闭

发布于 12-24 20:19

window.closed 表示引用的窗口是否已关闭,属性只读


值:

  • true 窗口已被关闭
  • flase 窗口还是打开的


let refWindow = null;

function openWindow() {
  // 还没打开窗口或是窗口已被关闭
  if (!refWindow || refWindow.closed) {
      refWindow = window.open("xxx.html", "windowName");
  }
}