<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">
<title>Div+CSS+JS树型菜单,可刷新</title>
<metaname="description"content="http://www.livepo.com">
<styletype="text/css">
<!--
*{margin:0;padding:0;border:0;}
body{font-family:arial,宋体,serif;font-size:12px;}
#nav{width:180px;line-height:24px;list-style-type:none;text-align:left;/*定义整个ul菜单的行高和背景色*/}
/*==================一级目录===================*/
#nava{width:160px;display:block;padding-left:20px;/*Width(一定要),否则下面的Li会变形*/}
#navli{background:#CCC;/*一级目录的背景色*/border-bottom:#FFF1pxsolid;/*下面的一条白边*/float:left;/*float:left,本不应该设置,但由于在Firefox不能正常显示继承Nav的width,限制宽度,li自动向下延伸*/}
#navlia:hover{background:#CC0000;/*一级目录onMouseOver显示的背景色*/}
#nava:link{color:#666;text-decoration:none;}
#nava:visited{color:#666;text-decoration:none;}
#nava:hover{color:#FFF;text-decoration:none;font-weight:bold;}
/*==================二级目录===================*/
#navliul{list-style:none;text-align:left;}
#navliulli{background:#EBEBEB;/*二级目录的背景色*/}
#navliula{padding-left:20px;width:160px;/*padding-left二级目录中文字向右移动,但Width必须重新设置=(总宽度-padding-left)*/}
/*下面是二级目录的链接样式*/
#navliula:link{color:#666;text-decoration:none;}
#navliula:visited{color:#666;text-decoration:none;}
#navliula:hover{color:#F3F3F3;text-decoration:none;font-weight:normal;background:#CC0000;/*二级onmouseover的字体颜色、背景色*/}
/*==============================*/
#navli:hoverul{left:auto;}
#navli.sfhoverul{left:auto;}
#content{clear:left;}
#navul.collapsed{display:none;}
#PARENT{width:300px;padding-left:20px;}
/*==================三级目录===================*/
#navliulliul{list-style:none;text-align:left;}
#navliulliulli{background:#EBEBEB;/*二级目录的背景色*/}
#navliulliullia{padding-left:20px;width:160px;/*padding-left二级目录中文字向右移动,但Width必须重新设置=(总宽度-padding-left)*/}
/*下面是二级目录的链接样式*/
#navliulliullia:link{color:#666;text-decoration:none;}
#navliulliullia:visited{color:#666;text-decoration:none;}
#navliulliullia:hover{color:#F3F3F3;text-decoration:none;font-weight:normal;background:#CC0000;/*二级onmouseover的字体颜色、背景色*/}
-->
</style>
</head>
<body>
<divid="PARENT">
<ulid="nav">
<li><ahref="#Menu=ChildMenu1"οnclick="DoMenu('ChildMenu1')">1</a>
<ulid="ChildMenu1"class="collapsed">
<li><ahref="http://www.netany.net"target="_blank">11</a></li>
<li><ahref="http://www.netany.net"target="_blank">12</a></li>
<li><ahref="http://www.netany.net"target="_blank">13</a></li>
<li><ahref="http://www.netany.net"target="_blank">14</a></li>
</ul>
</li>
<li><ahref="#Menu=ChildMenu2"οnclick="DoMenu('ChildMenu2')">2</a>
<ulid="ChildMenu2"class="collapsed">
<li><ahref="#">21</a></li>
<li><ahref="#">22</a></li>
<li><ahref="#">23</a></li>
<li><ahref="#">24</a></li>
<li><ahref="#">25</a></li>
<li><ahref="#">26</a></li>
<li><ahref="#">27</a></li>
<li><ahref="#">28</a></li>
</ul>
</li>
<li><ahref="#Menu=ChildMenu3"οnclick="DoMenu('ChildMenu3')">3</a>
<ulid="ChildMenu3"class="collapsed">
<li><ahref="#">b1</a></li>
<li><ahref="#">b2</a></li>
<li><ahref="#">b3</a></li>
</ul>
</li>
<li><ahref="#Menu=ChildMenu4"οnclick="DoMenu('ChildMenu4')">4</a>
<ulid="ChildMenu4"class="collapsed">
<li><ahref="#">c1</a></li>
<li><ahref="#">c2</a></li>
<li><ahref="#">c3</a></li>
</ul>
</li>
<li><ahref="#Menu=ChildMenu5"οnclick="DoMenu('ChildMenu5')">5</a>
<ulid="ChildMenu5"class="collapsed">
<li><ahref="#">d1</a></li>
<li><ahref="#">d2</a></li>
<li><ahref="#">d3</a></li>
</ul>
</li>
<li><ahref="#Menu=ChildMenu6"οnclick="DoMenu('ChildMenu6')">6</a>
<ulid="ChildMenu6"class="collapsed">
<li><ahref="#">e1</a></li>
<li><ahref="#">e2</a></li>
<li><ahref="#">e3</a></li>
</ul>
</li>
<li><ahref="#Menu=ChildMenu7"οnclick="DoMenu('ChildMenu7')">7</a>
<ulid="ChildMenu7"class="collapsed">
<li><ahref="#">f1</a></li>
<li><ahref="#">f2</a></li>
<li><ahref="#">f3</a></li>
</ul>
</li>
<li><ahref="#Menu=ChildMenu8"οnclick="DoMenu('ChildMenu8')">8</a>
<ulid="ChildMenu8"class="collapsed">
<li><ahref="#">f1</a></li>
<li><ahref="#">f2</a></li>
<li><ahref="#">f3</a></li>
</ul>
</li>
</ul>
</div>
</body>
</html>
<scripttype=text/javascript><!--
varLastLeftID="";
functionmenuFix(){
varobj=document.getElementById("nav").getElementsByTagName("li");
for(vari=0;i<obj.length;i++){
obj[i].οnmοuseοver=function(){
this.className+=(this.className.length>0?"":"")+"sfhover";
}
obj[i].onMouseDown=function(){
this.className+=(this.className.length>0?"":"")+"sfhover";
}
obj[i].onMouseUp=function(){
this.className+=(this.className.length>0?"":"")+"sfhover";
}
obj[i].οnmοuseοut=function(){
this.className=this.className.replace(newRegExp("(?|^)sfhover\\b"),"");
}
}
}
functionDoMenu(emid)
{
varobj=document.getElementById(emid);
obj.className=(obj.className.toLowerCase()=="expanded"?"collapsed":"expanded");
if((LastLeftID!="")&&(emid!=LastLeftID))//关闭上一个Menu
{
document.getElementById(LastLeftID).className="collapsed";
}
LastLeftID=emid;
}
functionGetMenuID()
{
varMenuID="";
var_paramStr=newString(window.location.href);
var_sharpPos=_paramStr.indexOf("#");
if(_sharpPos>=0&&_sharpPos<_paramStr.length-1)
{
_paramStr=_paramStr.substring(_sharpPos+1,_paramStr.length);
}
else
{
_paramStr="";
}
if(_paramStr.length>0)
{
var_paramArr=_paramStr.split("&");
if(_paramArr.length>0)
{
var_paramKeyVal=_paramArr[0].split("=");
if(_paramKeyVal.length>0)
{
MenuID=_paramKeyVal[1];
}
}
/*
if(_paramArr.length>0)
{
var_arr=newArray(_paramArr.length);
}
//取所有#后面的,菜单只需用到Menu
//for(vari=0;i<_paramArr.length;i++)
{
var_paramKeyVal=_paramArr[i].split('=');
if(_paramKeyVal.length>0)
{
_arr[_paramKeyVal[0]]=_paramKeyVal[1];
}
}
*/
}
if(MenuID!="")
{
DoMenu(MenuID)
}
}
GetMenuID();//*这两个function的顺序要注意一下,不然在Firefox里GetMenuID()不起效果
menuFix();
--></script>
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=gb2312">
<title>Div+CSS+JS树型菜单,可刷新</title>
<metaname="description"content="http://www.livepo.com">
<styletype="text/css">
<!--
*{margin:0;padding:0;border:0;}
body{font-family:arial,宋体,serif;font-size:12px;}
#nav{width:180px;line-height:24px;list-style-type:none;text-align:left;/*定义整个ul菜单的行高和背景色*/}
/*==================一级目录===================*/
#nava{width:160px;display:block;padding-left:20px;/*Width(一定要),否则下面的Li会变形*/}
#navli{background:#CCC;/*一级目录的背景色*/border-bottom:#FFF1pxsolid;/*下面的一条白边*/float:left;/*float:left,本不应该设置,但由于在Firefox不能正常显示继承Nav的width,限制宽度,li自动向下延伸*/}
#navlia:hover{background:#CC0000;/*一级目录onMouseOver显示的背景色*/}
#nava:link{color:#666;text-decoration:none;}
#nava:visited{color:#666;text-decoration:none;}
#nava:hover{color:#FFF;text-decoration:none;font-weight:bold;}
/*==================二级目录===================*/
#navliul{list-style:none;text-align:left;}
#navliulli{background:#EBEBEB;/*二级目录的背景色*/}
#navliula{padding-left:20px;width:160px;/*padding-left二级目录中文字向右移动,但Width必须重新设置=(总宽度-padding-left)*/}
/*下面是二级目录的链接样式*/
#navliula:link{color:#666;text-decoration:none;}
#navliula:visited{color:#666;text-decoration:none;}
#navliula:hover{color:#F3F3F3;text-decoration:none;font-weight:normal;background:#CC0000;/*二级onmouseover的字体颜色、背景色*/}
/*==============================*/
#navli:hoverul{left:auto;}
#navli.sfhoverul{left:auto;}
#content{clear:left;}
#navul.collapsed{display:none;}
#PARENT{width:300px;padding-left:20px;}
/*==================三级目录===================*/
#navliulliul{list-style:none;text-align:left;}
#navliulliulli{background:#EBEBEB;/*二级目录的背景色*/}
#navliulliullia{padding-left:20px;width:160px;/*padding-left二级目录中文字向右移动,但Width必须重新设置=(总宽度-padding-left)*/}
/*下面是二级目录的链接样式*/
#navliulliullia:link{color:#666;text-decoration:none;}
#navliulliullia:visited{color:#666;text-decoration:none;}
#navliulliullia:hover{color:#F3F3F3;text-decoration:none;font-weight:normal;background:#CC0000;/*二级onmouseover的字体颜色、背景色*/}
-->
</style>
</head>
<body>
<divid="PARENT">
<ulid="nav">
<li><ahref="#Menu=ChildMenu1"οnclick="DoMenu('ChildMenu1')">1</a>
<ulid="ChildMenu1"class="collapsed">
<li><ahref="http://www.netany.net"target="_blank">11</a></li>
<li><ahref="http://www.netany.net"target="_blank">12</a></li>
<li><ahref="http://www.netany.net"target="_blank">13</a></li>
<li><ahref="http://www.netany.net"target="_blank">14</a></li>
</ul>
</li>
<li><ahref="#Menu=ChildMenu2"οnclick="DoMenu('ChildMenu2')">2</a>
<ulid="ChildMenu2"class="collapsed">
<li><ahref="#">21</a></li>
<li><ahref="#">22</a></li>
<li><ahref="#">23</a></li>
<li><ahref="#">24</a></li>
<li><ahref="#">25</a></li>
<li><ahref="#">26</a></li>
<li><ahref="#">27</a></li>
<li><ahref="#">28</a></li>
</ul>
</li>
<li><ahref="#Menu=ChildMenu3"οnclick="DoMenu('ChildMenu3')">3</a>
<ulid="ChildMenu3"class="collapsed">
<li><ahref="#">b1</a></li>
<li><ahref="#">b2</a></li>
<li><ahref="#">b3</a></li>
</ul>
</li>
<li><ahref="#Menu=ChildMenu4"οnclick="DoMenu('ChildMenu4')">4</a>
<ulid="ChildMenu4"class="collapsed">
<li><ahref="#">c1</a></li>
<li><ahref="#">c2</a></li>
<li><ahref="#">c3</a></li>
</ul>
</li>
<li><ahref="#Menu=ChildMenu5"οnclick="DoMenu('ChildMenu5')">5</a>
<ulid="ChildMenu5"class="collapsed">
<li><ahref="#">d1</a></li>
<li><ahref="#">d2</a></li>
<li><ahref="#">d3</a></li>
</ul>
</li>
<li><ahref="#Menu=ChildMenu6"οnclick="DoMenu('ChildMenu6')">6</a>
<ulid="ChildMenu6"class="collapsed">
<li><ahref="#">e1</a></li>
<li><ahref="#">e2</a></li>
<li><ahref="#">e3</a></li>
</ul>
</li>
<li><ahref="#Menu=ChildMenu7"οnclick="DoMenu('ChildMenu7')">7</a>
<ulid="ChildMenu7"class="collapsed">
<li><ahref="#">f1</a></li>
<li><ahref="#">f2</a></li>
<li><ahref="#">f3</a></li>
</ul>
</li>
<li><ahref="#Menu=ChildMenu8"οnclick="DoMenu('ChildMenu8')">8</a>
<ulid="ChildMenu8"class="collapsed">
<li><ahref="#">f1</a></li>
<li><ahref="#">f2</a></li>
<li><ahref="#">f3</a></li>
</ul>
</li>
</ul>
</div>
</body>
</html>
<scripttype=text/javascript><!--
varLastLeftID="";
functionmenuFix(){
varobj=document.getElementById("nav").getElementsByTagName("li");
for(vari=0;i<obj.length;i++){
obj[i].οnmοuseοver=function(){
this.className+=(this.className.length>0?"":"")+"sfhover";
}
obj[i].onMouseDown=function(){
this.className+=(this.className.length>0?"":"")+"sfhover";
}
obj[i].onMouseUp=function(){
this.className+=(this.className.length>0?"":"")+"sfhover";
}
obj[i].οnmοuseοut=function(){
this.className=this.className.replace(newRegExp("(?|^)sfhover\\b"),"");
}
}
}
functionDoMenu(emid)
{
varobj=document.getElementById(emid);
obj.className=(obj.className.toLowerCase()=="expanded"?"collapsed":"expanded");
if((LastLeftID!="")&&(emid!=LastLeftID))//关闭上一个Menu
{
document.getElementById(LastLeftID).className="collapsed";
}
LastLeftID=emid;
}
functionGetMenuID()
{
varMenuID="";
var_paramStr=newString(window.location.href);
var_sharpPos=_paramStr.indexOf("#");
if(_sharpPos>=0&&_sharpPos<_paramStr.length-1)
{
_paramStr=_paramStr.substring(_sharpPos+1,_paramStr.length);
}
else
{
_paramStr="";
}
if(_paramStr.length>0)
{
var_paramArr=_paramStr.split("&");
if(_paramArr.length>0)
{
var_paramKeyVal=_paramArr[0].split("=");
if(_paramKeyVal.length>0)
{
MenuID=_paramKeyVal[1];
}
}
/*
if(_paramArr.length>0)
{
var_arr=newArray(_paramArr.length);
}
//取所有#后面的,菜单只需用到Menu
//for(vari=0;i<_paramArr.length;i++)
{
var_paramKeyVal=_paramArr[i].split('=');
if(_paramKeyVal.length>0)
{
_arr[_paramKeyVal[0]]=_paramKeyVal[1];
}
}
*/
}
if(MenuID!="")
{
DoMenu(MenuID)
}
}
GetMenuID();//*这两个function的顺序要注意一下,不然在Firefox里GetMenuID()不起效果
menuFix();
--></script>