现在的位置: 首页 > 综合 > 正文

如何实现iframe高度的自适应

2019年11月16日 ⁄ 综合 ⁄ 共 489字 ⁄ 字号 评论关闭
  1. <script type="text/javascript">  
  2.     function reinitIframe(){  
  3.         var iframe = document.getElementById("frame_content");  
  4.         try{  
  5.             iframe.height =  iframe.contentWindow.document.documentElement.scrollHeight;  
  6.         }catch (ex){}  
  7.     }  
  8.   
  9.     window.setInterval("reinitIframe()", 200);  
  10. </script>  
  11. <iframe id="frame_content" src="iframe_b.html" scrolling="no" frameborder="0"></iframe>

一般情况是框架中的内容页 iframe_b.html高度不明时使用上述代码

具体分析见http://justcoding.iteye.com/blog/593559

抱歉!评论已关闭.