try{document.domain="jincin.com"}catch(error){}

需要在被调用的函数和调用函数出都要加入上面相同的语句

下面看一下第二种跨域的解决方案,当然是自己在他人的方法下实验的,结果很好使

该功能是解决了跨域的js修改iframe的高度

head.htm(http://xxx.com)

<!-- 登录弹出层 -->
  <div id="showLogin"  style="display: block;position:relative;z-index:-1;" onmouseout="document.getElementById('showLogin').style.zIndex=-1;">
   <iframe frameborder="0"  width="325" id="locallocation" style="position:absolute; top:0px; right:175px;" scrolling="no" src="http://yyy.com/login.htm"></iframe>
  </div>
  <script>
   document.getElementById("locallocation").src="http://yyy.com/login.htm?myURL='"+window.location.href+"'";
  </script>
 <!-- 登录层结束 -->

login.htm(http://yyy.com)

<iframe id="c_iframe"  height="0″ width="0"  src="http://xxx.com/common/logindiv.htm" style="display:none" ></iframe>
 
<script type="text/javascript">
  var myCssURL="";
  var para=window.location.search;
  var IndexOf=para.indexOf("myURL=");
  if(IndexOf > -1)
  {
   myCssURL=para.substring(IndexOf+7,para.length-1);//包括下一个字符myURL='
  }
        var b_width = Math.max(document.body.scrollWidth,document.body.clientWidth);
        
        var b_height = Math.max(document.body.scrollHeight,document.body.clientHeight);
        b_height=b_height+30;
        var c_iframe = document.getElementById("c_iframe");
        c_iframe.src = myCssURL+"/common/iframesize.htm"+"#"+b_width+"|"+b_height+"|0";
</script>

iframesize.htm(http://xxx.com)

<script type="text/javascript"> 
    var b_iframe =""; 
    var hash_url = window.location.hash;
    if(hash_url.indexOf("#")>=0)
    { 
        var hash_width = hash_url.split("#")[1].split("|")[0]+"px"; 
       var hash_height = hash_url.split("#")[1].split("|")[1]+"px";
       var divType = hash_url.split("#")[1].split("|")[2];
       if(divType == "0"){
        b_iframe = window.parent.parent.document.getElementById("locallocation"); 
       }
       else{
        b_iframe = window.parent.parent.document.getElementById("popdiv");
       }
     
        b_iframe.style.width = hash_width; 
        b_iframe.style.height = hash_height;
        b_iframe.style.zIndex=999;
    }
</script>

05-11 22:23