您好,欢迎访问一九零五行业门户网

父页面iframe高度自动适应子页面iframe高度_html/css_WEB-ITnose

//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;
}
其它类似信息

推荐信息