首页 > 其他 > 详细

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

时间:2015-05-12 18:27:02      阅读:235      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!