iframe框架調用高度自適應方法_帝國Cms教程

      編輯Tag賺U幣
      教程Tag:暫無Tag,歡迎添加,賺取U幣!
      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> 
      有需要的可以記錄下來,希望可以幫助到你。

      查看更多 帝國cms教程  帝國cms模板

      來源:模板無憂//所屬分類:帝國Cms教程/更新時間:2020-06-02
      相關帝國Cms教程