码迷,mamicode.com
首页 > 其他好文 > 详细

Iframe 高度自适应的问题

时间:2014-10-21 19:14:09      阅读:164      评论:0      收藏:0      [点我收藏+]

标签:高度自适应   style   color   io   ar   java   sp   div   on   

外层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 高度自适应的问题

标签:高度自适应   style   color   io   ar   java   sp   div   on   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!