http://www.kuqin.com/webpagedesign/20080516/8536.html 原创链接,由于里面有例子,转载的时候麻烦,所以此处注明
<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>
本文介绍了一种使用JavaScript实现IFrame自适应高度的方法。通过定时调整IFrame的高度以匹配其内容的实际高度,确保了良好的用户体验并提高了页面加载效率。
2529

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



