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。

  • 相关阅读:
    STM32CubeMX 使用
    Zookeeper集群搭建
    golang zookeeper监听事件报错
    git push 报错
    springboot使用postgresql模式下数据库表找不到
    不要在循环中访问数据库,这样会严重影响数据库性能
    SQL查询效率(Oracle)
    游标 数据集 效率比较
    oracle 视图
    INDEX SKIP SCAN 和 INDEX RANGE SCAN以及索引会失效
  • 原文地址:https://www.cnblogs.com/luckystar2010/p/3450028.html
Copyright © 2011-2022 走看看