1、父级页面
2、父级js
window.adjustHeight = function() {
var iframeEle = $("#iframe").get(0);
// contentDocument:获取iframe的document对象 contentWindow:获取iframe的window对象
var iframeDocumentObj = iframeEle.contentDocument || iframeEle.contentWindow.document;
var height = $(iframeDocumentObj).find("html").outerHeight(true) + 30;
$("#iframe").height(height);
}
3、iframe页js
parent.adjustHeight()
由于加载的iframe页会存在数据加载,异步请求等,再去填充内容,导致页面获取的内容的高度不够,会出现滚动条。解决方法就是:在iframe页数据加载渲染完成之后,动态的调用父业面的更新高度方法,用户几乎是无感知的,而且不影响用户体验
希望能够帮助到大家,欢迎留言评论!