[Java教程]iFrame根据里面的内容给高度,
0 2015-09-01 18:00:46
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);
不过我觉得这样效果并不好~~
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);
这种有的页面行,有的不行~搞不懂~~~
本文网址:http://www.shaoqun.com/a/141402.html
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们:admin@shaoqun.com。
0