首页 > 其他 > 详细

Iframe 高度自适应的问题

时间:2014-10-21 19:12:32      阅读:322      评论:0      收藏:0      [点我收藏+]

外层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 高度重新生成

Iframe 高度自适应的问题

原文:http://www.cnblogs.com/leonkobe/p/4041095.html

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