iframe自适应高度
作者:fengyn 日期:2010-01-16
这个问题,在网上搜了一下,不过,大多都不能使用,因为使用了后,有时候能显示,有时候不能显示。
下面的这个代码没问题。
<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>
宽带可以自己设置
下面的这个代码没问题。
<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>
宽带可以自己设置
评论: 0 | 引用: 0 | 查看次数: -
发表评论

上一篇
下一篇

文章来自:
Tags:
相关日志:
