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);
<iframe id="frame_content" src="../modules.php?app=blog_list&sort_id=" width="960" onload="this.height=100" frameborder="0" scrolling="no"></iframe>
本文介绍了一种通过JavaScript定时调整IFrame元素高度的方法,确保IFrame能够根据其内容自动伸缩,提高网页布局的灵活性与用户体验。
1776

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



