最近遇到个跨域调用的问题。
我在主页面中用iframe打开一个子页面,父页面使用http协议,而子页面使用的是https协议,两者在同一个域。
但是子页面无法调用父页面中任何内容,如果子页面使用http协议则可以。
哪位大大有此问题的解决方案?

解决方案 »

  1.   

    跨域可以用script 标签// 动态导入js
    function include(src,encoding,fun) 

        var s = $C('script');   
        s.type='text/javascript';
        s.charset=encoding; //'gb2312';
        s.src = src;   
        var tags =$$('head');   
       if(typeof(fun)=='function'){
            if( document.all ){
               s.onreadystatechange = function(){
                    if(/(complete|loaded)/.test(this.readyState)){
                          fun(); s.onreadystatechange = null; s.parentNode.removeChild(s); 
                     }};
           }else{
                 s.onload = function(){  fun(); s.onload = null; s.parentNode.removeChild(s); };
           }
        } 
        tags[0].appendChild(s); 
    };include("XXX.XX?a=1&b=2","utf-8",function(){
    // 回调函数服务器端返回一个全局变量,response.write("__rs={msg:'成功!',value:true}");
    if(__rs && __rs.value){
    alert(__rs.msg);
    __rs=null; 
    }
    });