iframe框架调用高度自适应方法_帝国Cms教程

iframe框架调用高度自适应方法

  1. <iframe frameborder="0" src="http://www.daixiao360.cn/" class="iframe" frameborder="0" id="test" onload="this.height=100" width="762px"  scrolling="no"></iframe> 
  2. <script type="text/javascript"> 
  3. function reinitIframe(){ 
  4. var iframe = document.getElementById("test"); 
  5. try{ 
  6. var bHeight = iframe.contentWindow.document.body.scrollHeight; 
  7. var dHeight = iframe.contentWindow.document.documentElement.scrollHeight; 
  8. var height = Math.max(bHeight, dHeight); 
  9. iframe.height = height; 
  10. console.log(height); 
  11. }catch (ex){} 
  12. window.setInterval("reinitIframe()", 200); 
  13. </script> 

有需要的可以记录下来,希望可以帮助到你。

dawei

【声明】:石嘴山站长网内容转载自互联网,其相关言论仅代表作者个人观点绝非权威,不代表本站立场。如您发现内容存在版权问题,请提交相关链接至邮箱:bqsm@foxmail.com,我们将及时予以处理。