解决上左右页面框架中iframe的引起的滚动条问题
js代码:
function setIframeHeight() {
var dHeight = 502; //基础高度
var main = document.getElementById("mainIframe");
var left = document.getElementById("leftIframe");
//var leftFrame = document.getElementsByName("left")[0];
var cHeight = main.contentWindow.document.body.scrollHeight; //当前高度
var sHeight = 0; //准备设置的高度值
if (cHeight <= dHeight) {
sHeight = dHeight + "px";
} else {
sHeight = cHeight + "px";
}
main.style.height = sHeight;
left.style.height = sHeight;
if (left.contentWindow.document.getElementById("leftFrameCont")) {
left.contentWindow.document.getElementById("leftFrameCont").style.height = sHeight;
}
}
var dHeight = 502; //基础高度
var main = document.getElementById("mainIframe");
var left = document.getElementById("leftIframe");
//var leftFrame = document.getElementsByName("left")[0];
var cHeight = main.contentWindow.document.body.scrollHeight; //当前高度
var sHeight = 0; //准备设置的高度值
if (cHeight <= dHeight) {
sHeight = dHeight + "px";
} else {
sHeight = cHeight + "px";
}
main.style.height = sHeight;
left.style.height = sHeight;
if (left.contentWindow.document.getElementById("leftFrameCont")) {
left.contentWindow.document.getElementById("leftFrameCont").style.height = sHeight;
}
}
index.jsp部分页面代码:
<div id="content_bottom2" style="width:auto;">
<iframe name="left" class="vipIf_left" scrolling="no" marginwidth="0px" frameborder="0" src="left.jsp" id="leftIframe"></iframe>
<iframe name="main" class="vipIf_right" frameborder="0" src="main.jsp" onload="setIframeHeight();" id="mainIframe"></iframe>
</div>
<iframe name="left" class="vipIf_left" scrolling="no" marginwidth="0px" frameborder="0" src="left.jsp" id="leftIframe"></iframe>
<iframe name="main" class="vipIf_right" frameborder="0" src="main.jsp" onload="setIframeHeight();" id="mainIframe"></iframe>
</div>
left.jsp部分页面代码:
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](http://www.blogjava.net/Images/dot.gif)
![](http://www.blogjava.net/Images/dot.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)