有时为了方便使用Iframe,但被潜入的页面长度不是固定的,显示滚动条不仅影响美观还对用户操作带来不便,自动调整高度可以解决这个问题。^_^
1<script language="JavaScript">
2
3function f_frameStyleResize(targObj){
4
5var targWin = targObj.parent.document.all[targObj.name];
6
7if(targWin != null) {
8
9var HeightValue = targObj.document.body.scrollHeight
10
11if(HeightValue < 600){HeightValue = 600} //不小于600
12
13targWin.style.pixelHeight = HeightValue;
14
15}
16
17}
18
19function f_iframeResize(){
20
21bLoadComplete = true; f_frameStyleResize(self);
22
23}
24
25var bLoadComplete = false;
26
27window.onload = f_iframeResize;
28
29</script>
** 注意:iframe必须要有name属性,否则无效。 **