iFrame 自适应高度

 

 

<iframe 
    src="http://www.fufuok.com/" 
    id="iframepage" 
    name="iframeID" 
    frameBorder=0 
    scrolling=no 
    width="100%" 
    onLoad="iFrameHeight()" 
></iframe>

 

 

<script type="text/javascript" language="javascript">  
  function iFrameHeight() {   
    var ifm=document.getElementById("iframeID");   
    var subWeb=document.frames?document.frames["iframeID"].document:
               ifm.contentDocument;   
    if(ifm != null && subWeb != null) {
      ifm.height = subWeb.body.scrollHeight;
    }   
  } 
</script>

 

 

用最简单的传统处理方式:
<iframe 
      id="frame_content" 
      src="iframe_b.html" 
      scrolling="no" 
      frameborder="0" 
      onload="this.height=this.contentWindow.document.documentElement.scrollHeight"
></iframe>
 

 

搞定!

 

 

 

 

 

你可能感兴趣的:(JavaScript)