1、问题描述:我在网上找了一段JS代码动态设置Iframe高度,如果Iframe中包含一个单一的页面是好用的,但是这个页面包含了两个TAB页 就 只能得到第一个TAB页内容的高度;
2、这样导致的问题是:如果第二个TAB页中内容的高度大于第一个TAB页中内容的高度,第二个TAB页中内容显示不全;
3、想要的解决方法:能不能动态获得Iframe中内容的高度时,哪个TAB中内容的高度最大就获取哪一个?
4、我下载的代码是这样的(请别找这段代码回复我):
function SetWinHeight(obj){
var win=obj;
if (document.getElementById){
if (win && !window.opera){
if (win.contentDocument && win.contentDocument.body.offsetHeight)
win.height = win.contentDocument.body.offsetHeight;
else if(win.Document && win.Document.body.scrollHeight)
win.height = win.Document.body.scrollHeight;
}
}
}<iframe name="frameReport" id="frameReport" allowtransparency="true" width="100%" height="100%" scrolling="no"
frameborder="0" border="0" noresize="noresize" framespacing="0" onLoad="Javascript:SetWinHeight(this)">
</iframe>
2、这样导致的问题是:如果第二个TAB页中内容的高度大于第一个TAB页中内容的高度,第二个TAB页中内容显示不全;
3、想要的解决方法:能不能动态获得Iframe中内容的高度时,哪个TAB中内容的高度最大就获取哪一个?
4、我下载的代码是这样的(请别找这段代码回复我):
function SetWinHeight(obj){
var win=obj;
if (document.getElementById){
if (win && !window.opera){
if (win.contentDocument && win.contentDocument.body.offsetHeight)
win.height = win.contentDocument.body.offsetHeight;
else if(win.Document && win.Document.body.scrollHeight)
win.height = win.Document.body.scrollHeight;
}
}
}<iframe name="frameReport" id="frameReport" allowtransparency="true" width="100%" height="100%" scrolling="no"
frameborder="0" border="0" noresize="noresize" framespacing="0" onLoad="Javascript:SetWinHeight(this)">
</iframe>
var H = 0
$(TAB).each(function(){
if (H <$(this).attr("scrollHeight")) H = $(this).attr("scrollHeight");
})
$(Iframe,parent.document).height(H)