62,046
社区成员
发帖
与我相关
我的任务
分享
<div id="content">
<iframe id="UFrame" name="UFrame" width="100%" frameborder="0" scrolling="yes" marginwidth="0" marginheight="0" ></iframe>
<script type="text/javascript">
function reinitIframe(){
var iframe = document.getElementById("UFrame");
try{
var bHeight = iframe.contentWindow.document.body.scrollHeight;
var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
var height = Math.max(bHeight, dHeight);
iframe.height = height;
}catch (ex){}
}
window.setInterval("reinitIframe()", 200);
</script>
</div>
function SetCwinHeight(){
var h;
if(navigator.userAgent.indexOf("MSIE")>0){
h = document.getElementById("panel-1022").clientHeight
- document.getElementById("header-1029").clientHeight;
}else{
h = document.getElementById("ext-gen1046").clientHeight;
}
document.getElementById("UFrame").height = h;
}
window.setInterval("SetCwinHeight()", 2000);
问题的原因找到了,IFRAME的高度需要的是clientHeight,网上搜出来的都是框架内容页面的scrollHeight。
EXTJS本身已经实现高度自适应了,所以简单的方法是直接去取框架外层DIV的高度重新设定下新的高度就可以。
在IE和非IE下有点不一样!是不是跟EXTJS在IE和非IE下的加载呈现顺序有关就不太清楚了。
<%@ Page Language="C#" AutoEventWireup="true" Inherits="Admin_Default" CodeFile="Default.aspx.cs" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>后台管理系统</title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<style type="text/css">
.navPoint {color: white; cursor: hand; font-family: Webdings; font-size: 9pt}
</style>
<script src="../Scripts/jquery-1.8.3.min.js"></script>
<script language="JavaScript" type="text/javascript">
/*
if (window.screen) {
var aw = screen.availWidth;
var ah = screen.availHeight;
window.moveTo(-3, -3);
window.resizeTo(aw+7, ah+7);
//
}
*/
function switchSysBar() {
jQuery("#frmTitle").stop();
if (document.getElementById("switchPoint").innerHTML == "<<") {
jQuery("#frmTitle").animate({ width: "hide", opacity: 'hide' }, "fast", function () {
jQuery("#frmTitle").hide();
document.getElementById("switchPoint").innerHTML = ">>"
_menu_width = 0;
jQuery(window).resize();
});
} else {
jQuery("#frmTitle").animate({ width: "show", opacity: 'show' }, "fast", function () {
jQuery("#frmTitle").show();
document.getElementById("switchPoint").innerHTML = "<<"
_menu_width = 171;
jQuery(window).resize();
});
}
}
</script>
</head>
<style>
body{width:100%; height:auto; overflow-y:hidden; overflow-x:auto; padding:0px; margin:0px;}
#Right{
scrollbar-arrow-color: #f4ae21; /*图6,三角箭头的颜色*/
scrollbar-face-color: #333; /*图5,立体滚动条的颜色*/
scrollbar-3dlight-color: #666; /*图1,立体滚动条亮边的颜色*/
scrollbar-highlight-color: #666; /*图2,滚动条空白部分的颜色*/
scrollbar-shadow-color: #999; /*图3,立体滚动条阴影的颜色*/
scrollbar-darkshadow-color: #666; /*图4,立体滚动条强阴 影的颜色*/
scrollbar-track-color: #666; /*图7,立体滚动条背景颜色*/
scrollbar-base-color:#f8f8f8; /*滚动条的基本颜色*/
Cursor:url(mouse.cur); /*自定义个性鼠标*/
}
#dv_top ul,li{
list-style:none;
padding:0; margin:0;
font-size:14px;
}
#dv_top { border-bottom:1px #000 solid; height:auto; width:100%;}
#dv_top li{
margin-left:2px;float:left; background-color:#FFF; width:100px; padding-top:10px; height:20px; text-align:center;
border:1px #000 solid; border-bottom:none; font-weight:bold; color:#CCC; cursor:pointer;
}
#dv_top .sel
{
color:#2989F3; background-color:#E9FCFE
}
</style>
<body style="margin: 0px;overflow:hidden; height:100%;" scroll="no">
<script>
var thisClass;
jQuery(document).ready(function () {
jQuery("#dv_top li").click(function () {
jQuery(".dv_top").attr("class", "");
jQuery(this).attr("class", "dv_top sel");
thisClass = "dv_top sel";
window.open(jQuery(this).attr("menuUrl"), "Left");
});
});
</script>
<form id="form1" runat="server">
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
<tr>
<td height="50" colspan="3" align="left" valign="bottom" nowrap id="frmTitle2" background="<%= admin_res_path %>Images/login_06.gif" ><div id="dv_top" style="width:400px; height:auto; float:left;" >
<ul>
<li class="dv_top sel" onmouseover="thisClass=this.className;this.className='dv_top sel';" onmouseout="this.className=thisClass;" num="0" menuUrl="leftmenu_for_content.aspx">内容管理</li>
<li onmouseover="thisClass=this.className;this.className='dv_top sel';" onmouseout="this.className=thisClass;" style="display:;" num="2" menuUrl="leftmenu_for_system.aspx">系统设置</li>
</ul>
</div>
<div style="width:200px; height:auto; float:right; font-size:12px;" > <a href="ModiPassWord.aspx" target='Right' style="color:#FFFFFF;">修改密码</a> <a href="Login.aspx?acction=quit" style="color:#FFFFFF;">退出登陆</a> </div></td>
</tr>
<tr>
<td align="center" nowrap valign="top" id="frmTitle" height="100%"><iframe id="Left" class="ifram_autoheight" name="Left" src="leftmenu_for_content.aspx" scrolling="no" frameborder="0" style="width:171px;height:100%" > </iframe></td>
<td style="width: 9pt" height="100%" id="cc"><table border="0" cellpadding="0" cellspacing="0" height="100%" bgcolor="#599DE8">
<tr style="cursor:hand;">
<td id="qh" style="HEIGHT: 100%; width: 13px; cursor:pointer" onclick="switchSysBar()" title="点击关闭/打开左栏"><font style="FONT-SIZE: 9pt; CURSOR: default; COLOR: #ffffff"> <br/>
<br/>
<br/>
屏幕切换<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<span id="switchPoint" title="点击关闭/打开左栏"><<</span><br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
屏幕切换<br/>
<br/>
<br/>
<br/>
<br/>
</font></td>
</tr>
</table></td>
<td height="100%" width="100%" valign="top"><iframe frameborder="0" class="ifram_autoheight" id="Right" name="Right" scrolling="auto" src="Main.aspx" style="width:100%;height:100%;overflow-x:hidden;" > </iframe></td>
</tr>
</table>
</form>
<script>
var _content_height = 100;
var _content_width;
var _content_resize;
var _menu_width;
jQuery(document).ready(function () {
_content_width = jQuery(window).width() - jQuery("#frmTitle").width();
_menu_width = jQuery("#frmTitle").width();
jQuery(window).resize(function () {
jQuery("#Left").height(jQuery(window).height() - 50);
jQuery("#Left").contents().find(".menu").height(jQuery(window).height() - 50 - 68);
jQuery("#Right").height(jQuery(window).height() - 50);
jQuery("#Right").contents().find(".list").height(jQuery(window).height() - 50 - _content_height);
_content_width = jQuery(window).width() - _menu_width;
if (_content_resize != null) {
_content_resize();
}
});
jQuery("#Left").load(function () {
jQuery("#Left").height(jQuery(window).height() - 50);
jQuery("#Left").contents().find(".menu").height(jQuery(window).height() - 50 - 68);
});
jQuery("#Right").load(function () {
jQuery("#Right").height(jQuery(window).height() - 50);
jQuery("#Right").contents().find(".list").height(jQuery(window).height() - 50 - _content_height);
});
});
</script>
</body>
</html>