<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>
原文出自 http://www.kuqin.com/webpagedesign/20080516/8536.html
比较靠谱的iframe 自适应高度
最新推荐文章于 2021-07-17 09:08:42 发布
本文介绍了一种使IFrame元素能够自适应其内容高度的方法,通过JavaScript定时调整IFrame的高度,确保其能够精确匹配内部文档的实际高度。
794

被折叠的 条评论
为什么被折叠?



