由于不想使用滚动条,又不想固定框架的高度,想使他根据内容的多少而自动调整高度。
1. 主页面的框架代码:

 

<iframe id="ifr" src="test.html" width="660"  frameborder="0" scrolling="no" name="aa" id="aa"></iframe> 

 

2. 所嵌套子页面test.html在head添加脚本:

 

代码
<script language="JavaScript" type="text/javascript">
        
function f_frameStyleResize(targObj) {
            
var targWin = targObj.parent.document.all[targObj.name];
            
if (targWin != null) {
                
var HeightValue = targObj.document.body.scrollHeight
                
if (HeightValue < 500) { HeightValue = 500 }
                targWin.style.pixelHeight 
= HeightValue;
            }
        }
        
function f_iframeResize() {
            bLoadComplete 
= true; f_frameStyleResize(self);
        }
        
var bLoadComplete = false;
        window.onload 
= f_iframeResize;
    
</script>

 

 

相关文章:

  • 2021-12-12
  • 2021-12-12
  • 2021-10-10
猜你喜欢
  • 2021-07-18
  • 2022-01-20
  • 2022-12-23
  • 2021-12-29
  • 2021-12-12
  • 2021-06-28
相关资源
相似解决方案