首页 > 其他 > 详细

父页面iframe高度自动适应子页面iframe高度

时间:2015-04-02 11:42:55      阅读:275      评论:0      收藏:0      [点我收藏+]
//iframe自适应高度
function getHeight(id, name) {
document.documentElement.scrollTop = 0;
var ifm = document.getElementById(id);
var subWeb = document.frames ? document.frames[name].document :


ifm.contentDocument;


if (ifm != null && subWeb != null) {
ifm.height = subWeb.body.scrollHeight;


}
initParentHeight(); //这个是再初始化父页面的iframe的高度
}
function initParentHeight() //初始化父页面的iframe的高度

var div = window.parent.document.getElementById(‘mainFrame‘); 
div.style.height=window.document.body.scrollHeight||window.document.body.offsetHeight+5; 


父页面iframe高度自动适应子页面iframe高度

原文:http://blog.csdn.net/menghuannvxia/article/details/44829411

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!