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);

不过我觉得这样效果并不好~~

 

 

<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);

这种有的页面行,有的不行~搞不懂~~~


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM