Window.close()这句脚本是用来关闭当前窗口,如果是在window.open的窗口中执行Window.close(),将会很顺利地将窗口关闭,但如果是在一非window.open打开的窗口中执行Window.close(),将会弹出一个提示窗口,如下:

 

 

   要在程序中消除这个提示框也很简单,不过在IE6和IE7稍有不同

 

   1. IE6

 

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>IE6Close</title>
    <script type="text/javascript">
    function closeWin()
    {
        window.opener=null;
        window.close();
    }
    </script>
</head>
<body>
    <form />
    </div>
    </form>
</body>
</html>

 

   2.IE7

 

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>IE7Colse</title>
    <script type="text/javascript">
    function closeWin()
    {
        window.open('','_self','');
        window.close();
    }
    </script>
</head>
<body>
    <form />
    </div>
    </form>
</body>
</html>


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jame_peng/archive/2009/01/21/3846912.aspx

相关文章:

  • 2022-12-23
  • 2022-01-26
  • 2022-12-23
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-07
  • 2021-11-11
  • 2021-08-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-01
相关资源
相似解决方案