有了下面这个Div+CSS+JS树型菜单可刷新教程,不懂Div+CSS+JS树型菜单可刷新的也能装懂了,赶紧get起来装逼一下吧!
!DOCTYPE html PUBLIC "-//W3C//DTDXHTML1.0 Transitional//EN" ""
html xmlns=""
head
meta http-equiv="Content-Type" content="text/html; charset=gb2312"
titleDiv+CSS+JS树型菜单,可刷新/title
meta name="description" content=""
style type="text/css"
!--
*{;}
body {
font-family: arial, 宋体, serif;
;
}
#nav {
;
line-height: 24px;
list-style-type: none;
;
}
#nav a {
width: 160px;
display: block;
;
}
#nav li {
background:#CCC;
border-bottom:#FFF 1px solid;
;
}
#nav li a:hover{
background:#CC0000;
}
#nav a:link{
color:#666; ;
}
#nav a:visited{
color:#666;;
}
#nav a:hover{
color:#FFF;;font-weight:bold;
}
#nav li ul {
;
;
}
#nav li ul li{
background: #EBEBEB;
}
#nav li ul a{
;
;
}
#nav li ul a:link{
color:#666; ;
}
#nav li ul a:visited{
color:#666;;
}
#nav li ul a:hover {
color:#F3F3F3;
;
;
background:#CC0000;
}
#nav ul {
left: auto;
}
#nav ul {
left: auto;
}
#content {
clear: left;
}
#nav {
display: none;
}
--
#PARENT{
;
;
}
/style
/head
body
div
ul
lia href="/index.php#Menu=ChildMenu1"onclick="DoMenu('ChildMenu1')"我的网站/a
ul
lia href="http://www." target="_blank"[url]
lia href="http://www." target="_blank"[url]
lia href="http://www." target="_blank"[url]
/ul
/li
lia href="/index.php#Menu=ChildMenu2"我的帐务/a
ul
a href="http://www." target="_blank"支付/a/li
lia href="/index.php#"网上支付/a/li
lia href="/index.php#"登记汇款/a/li
lia href="/index.php#"在线招领/a/li
lia href="/index.php#"历史帐务/a/li
/ul
/li
lia href="/index.php#Menu=ChildMenu3"网站管理/a
ul
lia href="/index.php#"登录/a/li
a href="http://www." target="_blank"管理/a/li
lia href="/index.php#"管理/a/li
lia href="/index.php#"管理/a/li
/ul
/li
lia href="/index.php#Menu=ChildMenu4"网站管理/a
ul
lia href="/index.php#"登录/a/li
a href="http://www." target="_blank"管理/a/li
lia href="/index.php#"管理/a/li
lia href="/index.php#"管理/a/li
/ul
/li
/ul
/div
div
/br/br
工作需要搞了一个菜单,分享给大家,大家一齐学习
/br/br
请大家支持:a href="http://www." target="_blank"[url]http://www.[/url]/a
/div
/body
/html
script type=text/javascript!--
var LastLeftID = "";
function menuFix() {
var obj = ("")("");
for (var i=0; ; i++) {
obj[i].onmouseover=function() {
this.className+=(this.className.length0? " ": "") + "sfhover";
}
obj[i].onMouseDown=function() {
this.className+=(this.className.length0? " ": "") + "sfhover";
}
obj[i].onMouseUp=function() {
this.className+=(this.className.length0? " ": "") + "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.length0)
{
var _paramKeyVal = _paramArr[0].split("=");
if (_paramKeyVal.length0)
{
MenuID = _paramKeyVal[1];
}
}
}
if(MenuID!="")
{
DoMenu(MenuID)
}
}
GetMenuID();//*这两个function的顺序要注意一下,不然在Firefox里GetMenuID()不起效果
menuFix();
--/script