源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

javascript消除window.close()的提示窗口

  • 时间:2021-06-09 05:37 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:javascript消除window.close()的提示窗口
Window.close()这句脚本是用来关闭当前窗口,如果是在window.open的窗口中执行Window.close(),将会很顺利地将窗口关闭,但如果是在一非window.open打开的窗口中执行Window.close(),将会弹出一个提示窗口,如下: [img]http://files.jb51.net/file_images/article/201505/2015052010561017.gif[/img] 要在程序中消除这个提示框也很简单,不过在IE6和IE7稍有不同 [b]1. IE6[/b]
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
  <title>IE6Close</title>
  <script type="text/javascript">
  function closeWin()
  {
    window.opener=null;
    window.close();
  }
  </script>
</head>
<body>
  <form id="form2" runat="server">
  <div>
    <input id="btnClose" type="button" value="close" onclick="closeWin()"/>
  </div>
  </form>
</body>
</html>
 
[b]2.IE7[/b]
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
  <title>IE7Colse</title>
  <script type="text/javascript">
  function closeWin()
  {
    window.open('','_self','');
    window.close();
  }
  </script>
</head>
<body>
  <form id="form2" runat="server">
  <div>
    <input id="btnClose" type="button" value="close" onclick="closeWin()"/>
  </div>
  </form>
</body>
</html>
以上所述就是本文的全部内容了,希望大家能够喜欢。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部