zoukankan      html  css  js  c++  java
  • iframe 解决跨域问题

    A项目(简称A:http://IP:8888/A)跨域访问B项目(简称B:http://IP:8080/B),IP不同实现页面嵌套与跨域访问方法问题

    1.A(a.jsp) 加载B(b.jsp)

    解决方案:

    a.jsp中创建iframe 

    <iframe id="crm_iframepage" width="100%" height="98%" src="http://IP:8080/B/b.jsp"  runat=server ></iframe>

    2.B(b.jsp)访问A(a.jsp)的方法

    解决方案:

    在B中b.jsp页面中使用js创建iframe对象,引入A中的中间页面a1.jsp

    <script type="text/javascript">

    var exec_obj = document.createElement('iframe');
    exec_obj.name = 'tmp_frame';
    exec_obj.src = 'http://IP:8888/A/a1.jsp?aa=bb'; //可以访问controller携带参数
    exec_obj.style.display = 'none';
    document.body.appendChild(exec_obj);

    </script>

    在a1.jsp页面中

    <script type="text/javascript">
    /*
    *调用的方法是a.jsp页面的abc方法,参数:aa
    */
    $(function(){
    parent.parent.abc('${aa}');
    });
    </script>

    我只尝试了通过B中b.jsp页面访问A中的controller,然后中转到指定页面(A的a1.jsp),指定页面在访问相同域(A)中a.jsp方法

    下面是参考资料:

    https://www.cnblogs.com/boystar/p/6909214.html

    https://www.cnblogs.com/HtmlCss3/p/6184252.html

  • 相关阅读:
    java 数组
    数组(二)
    JVM内存分配策略
    JVM垃圾收集算法
    LINUX 查看硬件配置命令
    遗传算法
    svn简单使用
    Several concepts in Data Mining
    JVM判断对象存活的算法
    JVM运行时数据区
  • 原文地址:https://www.cnblogs.com/chai-blogs/p/8554455.html
Copyright © 2011-2022 走看看