iframe 自适应高度

 

iframe 的自适应高度:

 

 

javaScript函数:

 

<script type="text/javascript"> 



function reinitIframe(){
var iframe  = document.getElementById("frame_content");
  try{
    
    var bHeight = iframe.contentWindow.document.body.scrollHeight;
    
    var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
 
	var height = Math.max(bHeight, dHeight);
 
	iframe.height =  height;
 
  }catch (ex){
  }
  
}
window.setInterval("reinitIframe()", 200);


 

 

 Html 代码:

<IFRAME id="frame_content" name="search_user"  onload="this.height=100" style="WIDTH: 100%;" marginWidth=1 marginHeight=1
src="/energy_portal/portal2User.do?actionType=userlistGroup"  frameBorder=0 scrolling=no>
</IFRAME>

 

你可能感兴趣的:(JavaScript,html)