><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内部文档的高度,并将其设置为iframe的高度,确保了iframe能够根据内容自动调整大小,避免了滚动条出现或者内容被截断的问题。
615

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



