您的位置:首页 > 其它

iframe高度自适应

2015-02-27 11:01 141 查看
function reinitIframe(fr){

var iframe = document.getElementById(fr);

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){}

}

<iframe id="the2" src="../living.html" width="640" height="100%" style="overflow-y: scroll" frameborder="0" scrolling="Auto"></iframe>

<script type="text/javascript">

window.setInterval("reinitIframe('the2')", 200);

</script>

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: