JS出于安全性的考虑,是禁止不同域间访问对方元素的。
楼主试试修改两个页面的domain属性,看看行不行。
引用2L的话,明知不可为而为之,就当自己是小白鼠吧。

解决方案 »

  1.   

    A域名
    a.html: <script type="text/javascript">document.domain='a.com';</script><iframe src="b域名/b.html" width="1000" height="0" border="0" marginwidth="0" marginheight="0" frameborder="no" scrolling="no" allowtransparency="yes" id="iframe" name="iframe"></iframe> a_proxy.html:
    <head></head>
    <body>
    <script>
    function  pseth() {
        var iObj = parent.parent.document.getElementById('iframe');
        var iObjH = window.location.hash;
        var height = parseInt(iObjH.split("#")[1]);
        if (height < 560) {
            height = 560;
        }
        iObj.style.height = height+"px";
    }
    try {
        document.domain='a.com';
        pseth();
    } catch(e){}
    </script>
    </body>
    </html>B域名
    b.html:增加代码<script type="text/javascript"> 
    function setHeight(){ 
    var dHeight = document.documentElement.scrollHeight; 
    var t = document.createElement("div"); 
    t.innerHTML = '<iframe id="iframeagent" src="a域名/a_proxy.html#'+dHeight+'"scrolling="yes" height="0px" width="0px"></iframe>'; 
    document.documentElement.appendChild(t.firstChild); 

    </script> <body onload="javascript: setHeight();">
    详情请看资讯网http://www.eeite.com/a/qianduan/20140513/25.html