您的位置:首页 > 其它

iframe自适应高度

2013-04-07 10:45 253 查看
无废话,网上很多文章一下写了几种实现方式,代码短点的呢用不了,长点的呢眼睛都看花

下面的代码在火狐、IE上正常

<script type="text/javascript">
function reinitIframe(){
var iframe = document.getElementById("mainFrame");
try{
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight);
iframe.height = height;
}catch (ex){}
}
window.setInterval("reinitIframe()", 200);
</script>

转载自http://www.jb51.net/article/26132.htm,Mark
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: