Iframe 高度自适应的问题

外层div ,div 内包含iframe  ;如何当内部iframe 高度变化时,外层的div 高度跟着自适应呢?

1:

<div>
<IFRAME height="100%" width="100%" frameBorder=0
id=inspfrmchild name= inspfrmchild scrolling="no"
onload="javascript:dyniframesize('inspfrmchild');"
src="${path }/inspect-Inspinfo-inspinfoDetial.do" allowTransparency="true">
</IFRAME>
</div>

2:

function dyniframesize(down) {
var pTar = null;
if (document.getElementById){
pTar = document.getElementById(down);
}
else{
eval('pTar = ' + down + ';');
}
if (pTar && !window.opera){
//begin resizing iframe
pTar.style.display="block"
if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){
//ns6 syntax
pTar.height = pTar.contentDocument.body.offsetHeight + 29;
pTar.width = pTar.contentDocument.body.scrollWidth;
}
else if (pTar.Document && pTar.Document.body.scrollHeight){
//ie5+ syntax
pTar.height = pTar.Document.body.scrollHeight;
pTar.width = pTar.Document.body.scrollWidth;
}
}
}

3:当内部iframe 动态变化时,可内部调用JS函数,将外部的div 高度重新生成

原文地址:https://www.cnblogs.com/leonkobe/p/4041095.html