zoukankan      html  css  js  c++  java
  • 模式窗体中调用父页面Javascript

    最近项目中使用模式窗体,遇到以下问题记录一下:

    模式窗体:你必须关闭该窗体,才能操作其它窗体;比如说,必须按确定或取消,或者按关闭。

    非模式窗体:不必关闭该窗体,就可转换到其它窗体上进行操作。

    window.showModalDialog("a.html");//模式窗体

    弹出的子页面,无法调用父页面里的js,从而刷新父页面,google一下,发现了解决方案:

    1. parent.html
    <html>
    <head>
    <script language="text/javascript">
    function openwindow(){
        retval=window.showModalDialog("child.html")
        Alert(retval);
        document.getElementById('text1').value=retval
    }
    
    function Alert(msg){
        alert(msg);
    }
    </script>
    </head>
    <body>
    <form name=frm>
    <input name=text1 type=text id="text1"/>
    <input type=button onclick="javascript:openwindow()" value="Open window..">
    </form>
    </body>
    </html>

    2. child.html

    <html>
    <head>
    <script language="javascript">
    function changeparent(){
        window.returnValue="Value changed.."
        window.close()
    }
    </script>
    </head>
    <body>
    <form>
    <input type=button onclick="javascript:changeparent()" value="Change main window’s textbox value..">
    </form>
    </body>
    </html>
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接。
  • 相关阅读:
    C++相关资料
    OpenCV相关资料参考
    QT-undefined reference to vtable
    QToolButton弹出菜单
    QT-信号和槽机制
    了解字符集和编码
    apache配置Directory目录权限的一些配置
    linux用户(组)及文件权限说明
    Linux下重要日志文件及查看方式
    四种常见的 POST 提交数据方式
  • 原文地址:https://www.cnblogs.com/wspaceworld/p/3836821.html
Copyright © 2011-2022 走看看