HTML DOM closed ÊôÐÔ

¶¨ÒåºÍÓ÷¨

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>
VUE