如果网页不是通过脚本程序打开的(window.open()),调用window.close()脚本关闭窗口前,必须先将window.opener对象置为null,否则浏览器(IE7、IE8)会弹出一个确定关闭的对话框。

<script language="javaScript">
  function closeWindow()
  {
     window.opener = null;
     window.open(' ', '_self', ' ');
     window.close();
  }
</script>

<input type='button' value='关闭窗口' onClick="closeWindow()">   

<input type="button" value="关闭窗口" onClick="window.opener = null; window.open(' ', '_self', ' ');window.close()">

 

对于关闭框架窗口
<script language="javaScript">
  function closeWindow()
  {  
       window.opener = null;  
       window.open('', '_top', '');  
       window.parent.close(); 
  } 
</script>

0
0
0
(请您对文章做出评价)

相关文章:

  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-23
  • 2022-01-26
  • 2022-12-23
  • 2021-05-16
  • 2021-10-08
相关资源
相似解决方案