根据页面的内容,动态设置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>
下一篇: Four Letter Words