根据内容自动调整IFrame高度

根据内容自动调整IFrame高度

有时为了方便使用Iframe,但被潜入的页面长度不是固定的,显示滚动条不仅影响美观还对用户操作带来不便,自动调整高度可以解决这个问题。

[复制到剪切板]
CODE:
<SCRIPT LANGUAGE="JavaScript">

function 
f_frameStyleResize(targObj){

var 
targWin targObj.parent.document.all[targObj.name];

if(
targWin != null) {

var 
HeightValue targObj.document.body.scrollHeight

if(HeightValue 600){HeightValue 600//不小于600

targWin.style.pixelHeight HeightValue;

}

}

function 
f_iframeResize(){

bLoadComplete truef_frameStyleResize(self);

}

var 
bLoadComplete false;

window.onload f_iframeResize;

<\/
script> ;

  注意:iframe必须要有name属性,否则无效。
如履薄冰

請問iframe是不是只能在擴展名是html,htm的文件才起作用?

111111

1111