zoukankan      html  css  js  c++  java
  • window.returnValue跨域传值问题[转]

    主页面用window.showModalDialog的时候,如果直接打开其它系统的页面,这时候别人的页面在window.returnValue=1;这样返回值的时候,主页面是取不到返回值的,原因就是因为跨域了.
    解决办法如下:
    1,首先主页面testMain.jsp先打开一个中转页面,
    Java代码
    <html>
    <head>
    </head>
    <body>
    <input type="button" value="test" onclick="test();"/>
    </body>
    </html>
    <script type="text/javascript">
    function test() {
    var paramObj = new Object();
    //弹出模式窗口,集成页面
    var ret_Value = window.showModalDialog("testFrame.jsp",paramObj,"scroll:no;resizable:yes;Minimize:no;Maximize:yes;dialogHeight:700px;dialogWidth:1024px;");
    alert("返回值---" + ret_Value);
    }
    </script>

    2,中转页面testFrame.jsp中要有一个iframe,然后把其它系统要打开的页面(这里的例子就是http://192.168.1.120:8080/test.jsp)放在这个iframe中,这里用一个FORM来存放要提交的数据,代码如下:
    Java代码
    <html>
    <body>
    <form id="page_interface_form" name="page_interface_form" method="post">
    <input type="hidden" value="测试数据11111111" name="data" />
    </form>
    <iframe name="page_interface_frame" width="100%" height="100%" ></iframe>
    </body>
    </html>
    <script type="text/javascript">
    //嵌入集成页面
    call_page_interface();
    //在iframe中调用页面集成接口
    function call_page_interface(){
    document.getElementById("page_interface_form").action = "http://192.168.1.120:8080/test.jsp";
    document.getElementById("page_interface_form").target = 'page_interface_frame';
    document.getElementById("page_interface_form").submit();
    }
    </script>

    亲测可用

     参考:http://download.csdn.net/download/hefang0711/7239985

  • 相关阅读:
    使用iframe从网页调起移动端应用
    综合练习:词频统计
    组合数据类型练习
    python 绘制五星红旗
    熟悉常用的Linux操作
    大数据概述
    windowBackground打造闪屏页
    安卓日期选择对话框
    c语言语法分析器
    C语言文法
  • 原文地址:https://www.cnblogs.com/barrysgy/p/4788695.html
Copyright © 2011-2022 走看看