您的位置:首页 > 其它

解决上左右页面框架中iframe的引起的滚动条问题

2009-09-21 15:13 543 查看
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;

}

}

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>

left.jsp部分页面代码:

<body>

<div class="cont_left" id="leftFrameCont">

</div>

</body>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐