zoukankan      html  css  js  c++  java
  • JS产生模态窗口,关闭后刷新父窗体。(兼容各浏览器)

    折腾了好久,终于搞出来了。参考资料

    http://www.cnblogs.com/davidyang78/archive/2011/07/29/2121278.html

    下面直接上源码,保证兼容ie,google,360,firefox

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
        <!--防止模态窗口提交form时再弹出一个新窗口-->
        <base target="_self" />
        <script type="text/javascript">
            function DialogWin(url, width, height) { height = height + 50; if (url.indexOf('.aspx?', 0) > 0) { url = url + '&t=' + Math.random(); } else { url = url + '?&t=' + Math.random(); } return window.showModalDialog(url, window, ";dialogWidth:" + width + "px;dialogHeight:" + height + "px;center:1;scroll:auto;help:0;status:0;statusbars:0;location:0;menubar:0;toolbars:0;resizable:0;"); }
            function openClick() {
                var result = DialogWin("HtmlPage1.html", 500, 300);
                if (typeof (result) == 'undefined') {
                    result = window.ReturnValue;
                }
                if (result==true) {
                    window.location = window.location;
                }
            }
        </script>
    
    </head>
    <body>
        <input type="button" id="btnSub" onclick="openClick()" value="弹出" />
    </body>
    </html>
    父窗体
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
        <!--防止模态窗口提交form时再弹出一个新窗口-->
        <base target="_self" />
        <script type="text/javascript">
            if (typeof (window.opener) == 'undefined')
                window.opener = window.dialogArguments;
            function sureClick() {
                window.retureValue = true;
                if (window.opener && window.opener != null) {
                    window.opener.ReturnValue = true;
                }
                window.close();
            }
        </script>
    
    </head>
    <body>
        <input type="button" id="btnSub" onclick="sureClick()" value="确定" />
    </body>
    </html>
    子窗体
  • 相关阅读:
    [BZOJ]1018 堵塞的交通(SHOI2008)
    [BZOJ]1069 最大土地面积(SCOI2007)
    HDU5739:Fantasia——题解
    洛谷6186:[NOI Online 提高组]冒泡排序——题解
    洛谷4631 & UOJ415 & LOJ2586:[APIO2018] Circle selection 选圆圈——题解
    洛谷2014:[CTSC1997]选课——题解
    洛谷2758:编辑距离——题解
    洛谷4148 & BZOJ4066:简单题——题解
    洛谷4357 & BZOJ4520:[CQOI2016]K远点对——题解
    洛谷4320:道路相遇——题解
  • 原文地址:https://www.cnblogs.com/xushining/p/3941958.html
Copyright © 2011-2022 走看看