打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
【网页特效】带记忆功能的二级下拉竖向导航菜单
<!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>
<title>带记忆功能的二级下拉竖向导航菜单</title>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<!--把下面代码加到<head>与</head>之间-->
<style type="text/css">
body {margin:0;text-align:center;color:#000;font:normal 12px Arial,Verdana,Tahoma;text-align:center;background:#C8D0D5;line-height:150%;}
a:link,a:visited {color:#385065;text-decoration:none}
a:hover {text-decoration:underline}
#menu {width:150px;margin:0px 15px;padding:0px;text-align:left;list-style:none}
#menu .item {margin:5px 0px;padding:0px;list-style:none}
a.title:link, a.title:visited, a.title:hover {display:block;background:url(/teixiao/UploadFiles_4612/201105/20110519100850302.gif) no-repeat;color:#385065;font-weight:bold;padding:2px 0 0 22px;width:128px;line-height:23px;cursor:pointer;text-decoration:none}
#menu .item ul {border:1px solid #9FACB7;margin:0;width:118px;padding:3px 0px 3px 30px;background:#fff;list-style:none;display:none}
#menu .item ul li {display:block;}
</style>
<script language="javascript" type="text/javascript">
// --- 获取ClassName
document.getElementsByClassName = function(cl) {
 var retnode = [];
 var myclass = new RegExp('\\b'+cl+'\\b');
 var elem = this.getElementsByTagName('*');
 for (var j = 0; j < elem.length; j++) {
  var classes = elem[j].className;
  if (myclass.test(classes)) retnode.push(elem[j]);
 }
 return retnode;
}
// --- 隐藏所有
function HideAll() {
 var items = document.getElementsByClassName("optiton");
 for (var j=0; j<items.length; j++) {
  items[j].style.display = "none";
 }
}
// --- 设置cookie
function setCookie(sName,sValue,expireHours) {
 var cookieString = sName + "=" + escape(sValue);
 //判断是否设置过期时间
 if (expireHours>0) {
   var date = new Date();
   date.setTime(date.getTime + expireHours * 3600 * 1000);
   cookieString = cookieString + "; expire=" + date.toGMTString();
 }
 document.cookie = cookieString;
}
//--- 获取cookie
function getCookie(sName) {
  var aCookie = document.cookie.split("; ");
  for (var j=0; j < aCookie.length; j++){
 var aCrumb = aCookie[j].split("=");
 if (escape(sName) == aCrumb[0])
   return unescape(aCrumb[1]);
  }
  return null;
}
/*
//默认第一个菜单打开
window.onload = function() {
 var show_item = "opt_1";
 if (getCookie("show_item") != null) {
   show_item= "opt_" + getCookie("show_item");
 }
 document.getElementById(show_item).style.display = "block";
 var items = document.getElementsByClassName("title");
 for (var j=0; j<items.length; j++) {
  items[j].onclick = function() {
   var o = document.getElementById("opt_" + this.name);
   if (o.style.display != "block") {
    HideAll();
    o.style.display = "block";
    setCookie("show_item",this.name);
   }
   else {
    o.style.display = "none";
   }
  }
 }
}
*/
//默认所有菜单全部关闭
window.onload = function () {
 var show_item = getCookie("show_item");
 if (show_item != null) {
  document.getElementById("opt_" + show_item).style.display = "block";
 }
 var items = document.getElementsByClassName("title");
 for (var j = 0; j < items.length; j++) {
  items[j].onclick = function () {
   var o = document.getElementById("opt_" + this.name);
   if (o.style.display != "block") {
    HideAll();
    o.style.display = "block";
    setCookie("show_item", this.name);
   }
   else {
    o.style.display = "none";
   }
  }
 }
}
</script>
</head>
<body>
<!--把下面代码加到<body>与</body>之间-->
<ul id="menu">
 <li class="item"><a href="javascript:void(0)" class="title" name="1">基本信息</a>
   <ul id="opt_1" class="optiton">
    <li><a href="1.html">基本简介</a></li>
    <li><a href="2.html">基本新闻</a></li>
   </ul>
 </li>
 <li class="item"><a href="javascript:void(0)" class="title" name="2">高级信息</a>
   <ul id="opt_2" class="optiton">
    <li><a href="3.html">高级简介</a></li>
    <li><a href="4.html">高级新闻</a></li>
   </ul>
 </li>
 <li class="item"><a href="javascript:void(0)" class="title" name="3">系统管理</a>
   <ul id="opt_3" class="optiton">
    <li><a href="5.html">会员管理</a></li>
    <li><a href="6.html">管理设置</a></li>
    <li><a href="7.html">权限设置</a></li>
    <li><a href="8.html">退出系统</a></li>
   </ul>
 </li>
</ul>
</body>
</html>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
DIV CSS标准蓝色菜单(2) 网页特效代码
Zen Coding 让 Notepad++ 代码书写健步如飞
notepad 结合Zen Coding快速编写HTML代码 | css3教程
WebStorm快捷键收集
jQuery 学习笔记之六 (jQuery DOM的操作)
jQuery性能优化指南(2)
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服