装载iframe 子页面,自适应高度

来源:互联网 发布:中国人存款数据 编辑:程序博客网 时间:2024/05/07 00:00
假设主页面有一个div,里面放置一个iframe
<div id="frameBox">
<iframe id="frameWin" src="1.html" name="opWin" style="width:100%; height:100% " frameborder="0"  scrolling="no"></iframe>
</div>
3个菜单链接,分别在iframe加载 1.html、2.html、3.html 三个页面。


3个子页面分别在自己页面加载完window.onload执行
function aa(){  
       var newHeight = document.body.scrollHeight + 20 + "px";       
       window.parent.document.getElementById("frameBox").style.height = newHeight;
       //以上firefox通过,但是ie6必须加上下面这句,不然iframe高度是改了,但是可见区域没有改
       window.parent.document.getElementById("frameWin").style.height = newHeight;
}
0 0
原创粉丝点击