如图,部门信息和机构列表两个window窗口,window窗口的函数是封装在框架的主页面的,这俩页面都是调用同一个window窗口的方法,两页面间不存在什么关系,我需要从机构列表取的值传到部门信息页面去,不知道如何传。
我的想法是在机构列表页面去调用部门信息页面的js方法,不知道怎么调用。页面是嵌套在iframe里的。
document.getElementById('windowIframe').contentWindow.ceshi() 这种方式不行。。

解决方案 »

  1.   

    父子页面传递控件、回调、值 参考:
    parentDialog.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>
        <link href="../JS/jquery-easyui-1.4/themes/gray/easyui.css" rel="stylesheet" />
    </head>
    <body>
        <iframe src="callParentDialog.html" style="width: 300px; height: 200px; border: 1px green solid;"></iframe>
        <div style="display: none;">
            <div id="dialog">
                <input id="test" type="text" value="这里的值将传回去" />
                <div id="ddd"><!--这里将接收子页面过来的控件--></div>
            </div>
        </div>
    </body>
    </html>
    <script src="../JS/jquery-easyui-1.4/jquery.min.js"></script>
    <script src="../JS/jquery-easyui-1.4/jquery.easyui.min.js"></script>
    <script type="text/javascript">
        function openDialog(callback, setText, container) {
            $('#ddd').append(setText);//将子页面的控件附加到对话框里面
            $('#dialog').dialog({
                title: '弹窗示例,关闭后回写数据',
                onClose: function () {
                    //这里回传一个对象回去,也可以传单个的值啥的
                    callback({ returnValue: document.getElementById('test').value });
                    //setText.value = "从父页面回写子页面对象";
                    $(container).append(setText);
                },
                modal:true
            });
        }
    </script>callParentDialog.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>
    </head>
    <body>
        <input type="button" value="打开窗体" onclick="openDig();" /><br />
        接收后回写值:<input id="ret" type="text" /><br />
        父页面写入值:<span id="sss"><input id="getText" type="text" value="这个是子页面的控件" /></span>
    </body>
    </html>
    <script type="text/javascript">
        function openDig() {
            parent.openDialog(function (v) {
                document.getElementById('ret').value = v.returnValue;
            }, document.getElementById('getText')
            , document.getElementById('sss'));
        }
    </script>