iframe高度自适应

来源:互联网 发布:多重网络怎么解决 编辑:程序博客网 时间:2024/06/07 11:18


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>
 

0 0