81,094
社区成员
发帖
与我相关
我的任务
分享
<iframe name="mainFrame" id="mainFrame" frameborder="0" scrolling="no" onload="changeFrameHeight()" src="${contextPath}/login/tab" ></iframe>
<script type="text/javascript">
function changeFrameHeight(){
var ifm= document.getElementById("mainFrame");
ifm.height=document.documentElement.clientHeight;
}
window.onresize=function(){
changeFrameHeight();
}
</script>
<body>
<div id="tab_menu"></div>
<div style="width:100%;">
<div id="page" style="width:100%;height:100%;"></div>
</div>
</body>
<script type="text/javascript">
function tabAddHandler(mid,mtitle,murl){
tab.update({
id :mid,
title :mtitle,
url :murl,
isClosed :true
});
tab.add({
id :mid,
title :mtitle,
url :murl,
isClosed :true
});
tab.activate(mid);
}
var tab;
$( function() {
tab = new TabView( {
containerId :'tab_menu',
pageid :'page', //内容区
cid :'tab1',
position :"top"
});
tab.add( {
id :'tab1_index1',
title :"个人首页",
url :"${contextPath}/teacherinfo/myselfinfo",
isClosed :false
});
});
function cmainFrameT(){
var hmainT = document.getElementById("page");
var bheightT = document.documentElement.clientHeight;
hmainT .style.width = '100%';
hmainT .style.height = (bheightT - 41) + 'px';
}
cmainFrameT();
window.onresize=function(){
cmainFrameT();
};
</script>
function reinitIframe(){
var iframe = document.getElementById("mainFrame");
try{
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight);
iframe.height = height;
//console.log(height);
}catch (ex){}
}
window.setInterval("reinitIframe()", 20);
以上代码是自适应屏幕的高度,就是不管屏幕分辨率多大,自适应。但是我在使用中还是会出现两个滚动条,但是内部的滚动条基本不需要拉动,希望对你有帮助