iFrame根據裏面的內容給高度,

<iframe src="member/membercenteraction"  frameborder="0"  scrolling="no" name="iframepage" width="100%" id="iframepage" onload="this.height=400"></iframe>

  

 

function iFrameHeight() {
  var iframe = document.getElementById("iframepage");
  var bHeight = iframe.contentWindow.document.body.scrollHeight;
  var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
  var height = Math.max(bHeight, dHeight);
  iframe.height = height;
}
window.setInterval("iFrameHeight()", 200);

不過我以爲這樣效果並很差~~javascript

 

 

<iframe src="member/membercenteraction"  frameborder="0"  scrolling="no" name="iframepage" width="100%" id="iframepage" onload="iFrameHeight()"></iframe>

 

function iFrameHeight() {
    var ifm= document.getElementById("iframepage");
    var subWeb=window.frames["iframepage"]. contentDocument || window.frames["iframepage"]. contentWindow.document;
    var subWeb = document.frames ? document.frames["iframepage"].document : ifm.contentDocument;
    if(ifm != null && subWeb != null) {
        ifm.height = subWeb.body.scrollHeight;
    }
}
window.setInterval("iFrameHeight()", 200);

這種有的頁面行,有的不行~搞不懂~~~java

相關文章
相關標籤/搜索