<iframe
src="http://www.fufuok.com/"
id="iframepage"
name="iframeID"
frameBorder=0
scrolling=no
width="100%"
onLoad="iFrameHeight()"
></iframe>
<script type="text/javascript" language="javascript">
function iFrameHeight() {
var ifm=document.getElementById("iframeID");
var subWeb=document.frames?document.frames["iframeID"].document:
ifm.contentDocument;
if(ifm != null && subWeb != null) {
ifm.height = subWeb.body.scrollHeight;
}
}
</script>
<iframe
id="frame_content"
src="iframe_b.html"
scrolling="no"
frameborder="0"
onload="this.height=this.contentWindow.document.documentElement.scrollHeight"
></iframe>
搞定!
本文介绍了一种使IFrame元素能够自动调整其高度以适应内部文档内容的方法。通过使用JavaScript监听IFrame加载完成事件,并设置IFrame的高度为内部文档的实际高度,可以实现无缝且美观的展示效果。
636

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



