欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

根据页面的内容,动态设置iframe的高度使其不出现滚动条

程序员文章站 2022-05-14 22:58:53
...

<iframe id="treeFrame" name="treeFrame" frameborder="0" scrolling="0" width="100%" src="Tree.jsp">
<iframe id="contentFrame" name="contentFrame" frameborder="0" scrolling="0" width="100%" src="content.jsp" stype="height:expression(1);aho:expression(autoResize())">
<script type="text/javascript">
function autoResize()
{
try{
var hr = contentFrame.document.body.scrollHeight;
var hl = treeFrame.document.body.scrollHeight;
var height = Math.max(hr,hl);
document.all["contentFrame"].style.height = height;
document.all["treeFrame"].style.height = height;
}
catch(e){}
}

</script>
相关标签: Java