var ifobj = document.getElementById("ifx");ifobj.height = ifobj.document.body.scrollHeight;
在Chrome下无效,郁闷。Ie和Opera都正常。

解决方案 »

  1.   

    这样试试:var ifobj = document.getElementById("ifx");
    ifobj.height = ifobj.document.body.scrollHeight||ifobj.document.documentElement.scrollHeight;
      

  2.   


    var iframe = document.getElementById("ifx");
    var doc = iframe.contentWindow.document;
    iframe.style.height = "auto";
    iframe.style.height = Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight) + "px";chrome下高度自适应确实有点怪,如果iframe里面的body、html样式为width:100%,height:100%就可能计算不正常了