我写的JS,但是只是在页面载入的时候可以满屏,我想要的效果就是高度能占满屏,不管什么情况下都随着浏览器的高度自动调整菜单的高度.我遇到的问题是:
我写的JS只能在页面载入的时候满屏,其它情况下不能,比如,切换第二行标签的时候,不能满屏,还有改变浏览器大小的时候,也不能
如何能实现根据浏览器的高度大小,动态改变菜单高度,让菜单占满屏?请大家给点方法,或是提示?急急急急!!!!
<script type="text/javascript">
var menuHeight=0;
if (document.documentElement.clientHeight>181){
    menuHeight=document.documentElement.clientHeight-181;
}
    else
        {menuHeight=0;}var getDiv=document.getElementsByTagName("div");for (var i=0;i<getDiv.length;i++){    if (getDiv[i].className=="tree_on"){
        getDiv[i].style.height=menuHeight;
    }
    }</script>
代码如下:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>登录页面</title>
<link rel="stylesheet" type="text/css" media="screen" href="http://www.woyaodo.com/download/logo/style/basic.css"/>
<script type="text/javascript" src="http://www.woyaodo.com/download/logo/js/yahoo.js"></script>
<script type="text/javascript" src="http://www.woyaodo.com/download/logo/js/event.js" ></script>
<script type="text/javascript" src="http://www.woyaodo.com/download/logo/js/dom.js" ></script>
<script type="text/javascript" src="http://www.woyaodo.com/download/logo/js/logger.js"></script>
<script type="text/javascript" src="http://www.woyaodo.com/download/logo/js/treeview-debug.js" ></script>
<script type="text/javascript" src="http://www.woyaodo.com/download/logo/js/changestyle.js"></script>
<script type="text/javascript" src="http://www.woyaodo.com/download/logo/js/date.js"></script>
<script type="text/javascript" src="http://www.woyaodo.com/download/logo/js/tree_data.js">></script>
<style type="text/css">
</style>
</head>
<body scroll="no">
<div id="container"> 
<!--Menu-->
<div id="navigation" class="default_width">
    <dl class="dl_on">
        <dt class="floder">
        <script type="text/javascript">document.write(y+"年"+m+"月"+d+"日");</script>
        </dt>
        <dd><span onclick="hidden_menu('treediv0')">第一行</span>
            <div class="tree_on" id="treediv0"> </div>
        </dd>
        <dd><span onclick="hidden_menu('treediv1')">第二行</span>
            <div class="tree_off" id="treediv1"> </div>
        </dd>
        <dd><span onclick="hidden_menu('treediv2')">第三行</span>
            <div class="tree_off" id="treediv2"> </div>
        </dd>
        <dd><span onclick="hidden_menu('treediv3')">第四行</span>
            <div class="tree_off" id="treediv3"> </div>
        </dd>
    </dl>
</div>
<!--Menu End-->
</div>
//我写的JS,但是只是在页面载入的时候可以满屏,我想要的效果就是高度能占满屏,不管什么情况下都随着浏览器的高度自动调整菜单的高度
<script type="text/javascript">
var menuHeight=0;
if (document.documentElement.clientHeight>181){
    menuHeight=document.documentElement.clientHeight-181;
}
    else
        {menuHeight=0;}
function reSetMenuHeight(){
var getDiv=document.getElementsByTagName("div");
for (var i=0;i<getDiv.length;i++){
    if (getDiv[i].className=="tree_on"){
        getDiv[i].style.height=menuHeight;
    }
    }
}
// onresize=reSetMenuHeight();
//alert(getDiv.length);
//alert(document.documentElement.clientHeight);
</script>
</body>
</html>

解决方案 »

  1.   

    http://topic.csdn.net/t/20051124/14/4415586.html
      

  2.   

    <body onresize="修改窗体大小()">
      

  3.   

    结贴
    to:zabcd117(菜园小哥) 我在页头必须得加上DTD,但是加了DTD,onresize不起作用了,没用
    解决方法,加个setinterval(function,200) 搞掂
      

  4.   

    不是没看,而是我在目标上已给onclick分配了另一个事件,还能再分配一个吗?
      

  5.   

    参考偶未发布过的页面:
    http://www.jxxg.com/dh20156/dhatv/manage.asp