码迷,mamicode.com
首页 > Web开发 > 详细

iframe切换内容页仍然能自适应大小代码(含js)

时间:2016-08-02 18:41:47      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:

function setIframeHeight(iframe) {
              if (iframe) {
                  var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
                  if (iframeWin.document.body) {
                      iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight;
                  }
              }
            };
            window.onload = function () {
                setIframeHeight(document.getElementById(‘myiframe‘));//iframe的id
}; 


<iframe onload="setIframeHeight(this)" id="myiframe" name="item-ifram" class="ZhaoShangJiaMeng-ifram" src="ZhaoShangJiaMeng-QuanYi.html" frameborder="0" scrolling="no" ></iframe>

 

iframe切换内容页仍然能自适应大小代码(含js)

标签:

原文地址:http://www.cnblogs.com/shark1100913/p/5729948.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!