点击这里给我发消息 点击这里给我发消息

Div+CSS+JS树型菜单,可刷新

添加时间:2011-7-20
    相关阅读: HTML CSS 网站
<!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>Div+CSS+JS树型菜单,可刷新</title>
<meta name="description" content="http://.knowsky.com">
<style type="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;
}
#nav a {
  width: 160px;
  display: block;
  padding-left:20px;
}
#nav li {
  background:#CCC;
  border-bottom:#FFF 1px solid;
  float:left;
}
#nav li a:hover{
  background:#CC0000; 
}
#nav a:link {
  color:#666; text-decoration:none;
}
#nav a:visited {
  color:#666;text-decoration:none;
}
#nav a:hover {
  color:#FFF;text-decoration:none;font-weight:bold;
}
#nav li ul {
  list-style:none;
  text-align:left;
}
#nav li ul li{  
  background: #EBEBEB;
}
#nav li ul a{
     padding-left:20px;
     width:160px;
}
  
#nav li ul a:link {
  color:#666; text-decoration:none;
}
#nav li ul a:visited {
  color:#666;text-decoration:none;
}
#nav li ul a:hover {
  color:#F3F3F3;
  text-decoration:none;
  font-weight:normal;
  background:#CC0000;
}
#nav li:hover ul {
  left: auto;
}
#nav li.sfhover ul {
  left: auto;
}
#content {
  clear: left;
}
#nav ul.collapsed {
  display: none;
}
-->
#PARENT{
  width:300px;
  padding-left:20px;
}
</style>
</head>
<body>
<div id="PARENT">
<ul id="nav">
<li><a href="http://j5c.ddvip.com/index.php#Menu=ChildMenu1" onclick="DoMenu('ChildMenu1')">我的网站</a>
  <ul id="ChildMenu1" class="collapsed">
  <li><a href="http://www.www.devdao.com" target="_blank">[url]www.www.devdao.com[/url]</a></li>
  <li><a href="http://www.www.devdao.com" target="_blank">[url]www.www.devdao.com[/url]</a></li>
  <li><a href="http://www.www.devdao.com" target="_blank">[url]www.www.devdao.com[/url]</a></li>
  </ul>
</li>
<li><a href="http://j5c.ddvip.com/index.php#Menu=ChildMenu2" onclick="DoMenu('ChildMenu2')">我的帐务</a>
  <ul id="ChildMenu2" class="collapsed">
  <a href="http://www.www.devdao.com" target="_blank">支付</a></li>
  <li><a href="http://j5c.ddvip.com/index.php#">网上支付</a></li>
  <li><a href="http://j5c.ddvip.com/index.php#">登记汇款</a></li>
  <li><a href="http://j5c.ddvip.com/index.php#">在线招领</a></li>
  <li><a href="http://j5c.ddvip.com/index.php#">历史帐务</a></li>
  </ul>
</li>
<li><a href="http://j5c.ddvip.com/index.php#Menu=ChildMenu3" onclick="DoMenu('ChildMenu3')">网站管理</a>
  <ul id="ChildMenu3" class="collapsed">
  <li><a href="http://j5c.ddvip.com/index.php#">登录</a></li>
  <a href="http://www.www.devdao.com" target="_blank">管理</a></li>
  <li><a href="http://j5c.ddvip.com/index.php#">管理</a></li>
  <li><a href="http://j5c.ddvip.com/index.php#">管理</a></li>
  </ul>
</li>
<li><a href="http://j5c.ddvip.com/index.php#Menu=ChildMenu4" onclick="DoMenu('ChildMenu4')">网站管理</a>
  <ul id="ChildMenu4" class="collapsed">
  <li><a href="http://j5c.ddvip.com/index.php#">登录</a></li>
  <a href="http://www.www.devdao.com" target="_blank">管理</a></li>
  <li><a href="http://j5c.ddvip.com/index.php#">管理</a></li>
  <li><a href="http://j5c.ddvip.com/index.php#">管理</a></li>
  </ul>
</li>
</ul>
</div>
<div style="width:300;padding-left:30px;">
</br></br>
工作需要搞了一个菜单,分享给大家,大家一齐学习
</br></br>
请大家支持:<a href="http://www.www.devdao.com" target="_blank">[url]http://www.www.devdao.com[/url]</a>
</div>
</body>
</html>
<script type=text/javascript><!--
var LastLeftID = "";
function menuFix() {
  var obj = document.getElementById("nav").getElementsByTagName("li");
  for (var i=0; i<obj.length; i++) {
    obj[i].onmouseover=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].onmouseout=function() {
      this.className=this.className.replace(new RegExp("( ?|^)sfhover"), "");
    }
  }
}
function DoMenu(emid)
{
  var obj = document.getElementById(emid);  
  obj.className = (obj.className.toLowerCase() == "expanded"?"collapsed":"expanded");
  if((LastLeftID!="")&&(emid!=LastLeftID))  //关闭上一个Menu
  {
    document.getElementById(LastLeftID).className = "collapsed";
  }
  LastLeftID = emid;
}
function GetMenuID()
{
  var MenuID="";
  var _paramStr = new String(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(MenuID!="")
  {
    DoMenu(MenuID)
  }
}
GetMenuID();  //*这两个function的顺序要注意一下,不然在Firefox里GetMenuID()不起效果
menuFix();
--></script> 本文作者:未知
咨询热线:020-85648757 85648755 85648616 0755-27912581 客服:020-85648756 0755-27912581 业务传真:020-32579052
广州市网景网络科技有限公司 Copyright◎2003-2008 Veelink.com. All Rights Reserved.
广州商务地址:广东省广州市黄埔大道中203号(海景园区)海景花园C栋501室
= 深圳商务地址:深圳市宝源路华丰宝源大厦606
研发中心:广东广州市天河软件园海景园区 粤ICP备05103322号 工商注册