码迷,mamicode.com
首页 > 其他好文 > 详细

iframe自适应高度计算,iframe自适应

时间:2015-05-12 18:28:51      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:

计算页面的实际高度,iframe自适应会用到
IfrHeight: function (iframeId, callback) {
  var height;
  function calcPageHeight(doc) {
  var cHeight = Math.max(doc.body.clientHeight, doc.documentElement.clientHeight);
  var sHeight = Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight);
  height = Math.max(cHeight, sHeight);
  return height;
}

var ifr = document.getElementById(ifId);

setTimeout(function () {
  var iDoc = ifr.contentDocument || ifr.document;
  height = calcPageHeight(iDoc);
  ifr.style.height = height + ‘px‘;
  callback(height);
  return height;
  }, 500);
},

iframe自适应高度计算,iframe自适应

标签:

原文地址:http://www.cnblogs.com/phone15138028025/p/4498095.html

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