关于iframe自适应高度问题

来源:互联网 发布:手机淘宝网手机淘宝 编辑:程序博客网 时间:2024/05/21 17:39

要使iframe的高度根据子页面的高度自动变化,在对象加载完后设置iframe的高度为子页面的滚动高度

代码:<iframe id="frame1" name="frame1" src="div2.jsp" width="100%"  frameborder="0" scrolling="no" onload="setAutoHeight('frame1','frame1');"></iframe>

<script type="text/javascript">

function setAutoHeight(id,name){
document.getElementById(id).style.height=document.frames[name].document.body.scrollHeight;
}

/script>

0 0