您的位置:首页 > 其它

如何控制iframe的高度随内容的多而自动增长

2009-11-02 19:57 253 查看
方法1:在iframe中加入name属性。然后加上onload="this.height=webb.document.body.scrollHeight+20"。例如:

<iframe src="huizAdd.jsp" width="100%" height="100%" scrolling="no" FrameBorder="0" id="webb" name="webb" onload="this.height=webb.document.body.scrollHeight+20"></iframe>

方法2:在被iframe调用的文件</body>之后加入上面这段即可。

<script language="javascript">
if (window.parent.length>0){window.parent.document.all.webb.style.height=document.body.scrollHeight;}
</script>
其中webb是iframe的name。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: