`
xiang37
  • 浏览: 414436 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

iframe 高度自适应 代码

阅读更多

<iframe id="frame_content" src="iframe_b.html" scrolling="no" frameborder="0" onload="this.height=100"></iframe>
<script type="text/javascript">
function reinitIframe(){
var iframe = document.getElementById("frame_content");
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>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics