zoukankan      html  css  js  c++  java
  • 无提示关闭弹出窗口

    主要代码:

    1 window.open('','_parent','');
    2 window.close();

    一个父子窗口的例子 :

    parent.html:

     1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
     2 <html>
     3 <head>
     4 <title> 父窗口</title>
     5 <meta name="Generator" content="EditPlus">
     6 <meta name="Author" content="">
     7 <meta name="Keywords" content="">
     8 <meta name="Description" content="">
     9 <script language="JavaScript">
    10 <!--
    11 
    12     function popupWin() {
    13         window.open('child.html','','');
    14     }
    15     function closeWindow() {
    16         window.open('','_parent','');
    17         window.close();
    18     }
    19 //-->
    20 </script>
    21 </head>
    22 
    23 <body>
    24     <input type="button" value="弹出子窗口" onclick="popupWin();">
    25     <input type="button" value="关闭窗口" onclick="closeWindow();">
    26 </body>
    27 </html>

    child.html:

     1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
     2 <html>
     3 <head>
     4 <title> New Document </title>
     5 <meta name="Generator" content="EditPlus">
     6 <meta name="Author" content="">
     7 <meta name="Keywords" content="">
     8 <meta name="Description" content="">
     9 </head>
    10 
    11 <body>
    12     <script language="JavaScript">
    13     <!--
    14         function closeWindow() {
    15             window.open('','_parent','');
    16             window.close();
    17         }
    18     //-->
    19     </script>
    20     <input type="button" value="关闭窗口" onclick="closeWindow();">
    21     
    22 </body>
    23 </html>

    如果是Firefox浏览器的话,需要将dom.allow_scripts_to_close_window设置为true。

    具体就是打开一个新的标签页,在地址栏输入about:config,回车。

    然后找到dom.allow_scripts_to_close_window,双击设置为true。

  • 相关阅读:
    springmvc+mybatis多数据源切换
    Tomcat 8.5 配置自动从http跳转https
    Tomcat 8.5 配置 域名绑定
    本地测试Tomcat配置Https访问
    Spring boot
    解决IDEA16闪退的问题
    cef
    spring-boot学习资料
    oracle 表空间不足解决办法
    oracle导出表的办法
  • 原文地址:https://www.cnblogs.com/luckystar2010/p/3450028.html
Copyright © 2011-2022 走看看