在做页面的时候经常会用到iframe,同样iframe的高度问题一直比较烦人。现在给术一个让iframe根据所包含页面的高度设置自己的高度。
调用本地文件,写法如下:
[code]<iframe id="test" src="test1.htm"
onload="this.height=test.document.body.scrollHeight"
frameborder="0"></iframe>[/code]
调用http页面,必须加上document.all.
[code]
document.all.test.height=document.all.test.document.body.scrollHeight
[/code]
调用本地文件,写法如下:
[code]<iframe id="test" src="test1.htm"
onload="this.height=test.document.body.scrollHeight"
frameborder="0"></iframe>[/code]
调用http页面,必须加上document.all.
[code]
document.all.test.height=document.all.test.document.body.scrollHeight
[/code]
iframe自适应高度技巧
本文介绍了一种让iframe根据其内部页面内容高度自动调整自身高度的方法。通过简单的代码实现,可以有效解决页面布局中iframe高度设定的问题。
1万+

被折叠的 条评论
为什么被折叠?



