IFrame自动适应宽高,去掉空白

主页调用iFrame如下:

<iframe src="Index.aspx" align=middle id="mainFrame" onload='this.height=document.frames["mainFrame"].document.body.scrollHeight' hspace="0" vspace="0" 
                                    WIDTH
='100%' marginwidth=0 MARGINHEIGHT=0 FRAMEBORDER='0' SCROLLING='no' ></iframe>

iFrame页(子页)调用JS函数,可调整主页调用的iFrame的高度

<SCRIPT LANGUAGE="JavaScript">
            
function frameStyleResize()
            {                
                
var HeightValue = document.body.scrollHeight;                    
                
if(HeightValue < 700)
                {    
                    HeightValue 
= 700;
                } 
                parent.document.getElementById(
"mainFrame").style.height = HeightValue;            
            }        
        
</SCRIPT>

<body onload="frameStyleResize();">
posted on 2007-11-05 16:11  Gary.han  阅读(2049)  评论(0编辑  收藏  举报