IS动态左侧菜单-01

 1 <%@ Page Language="C#" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
 2 
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 4 
 5 <html xmlns="http://www.w3.org/1999/xhtml" >
 6 <head runat="server">
 7 <meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
 8 <style id="Style1" type="text/css"  runat ="server" >
 9 body{margin:10px;padding:10px;}
10 body,h2,div,span,li{font-size:12px;}
11 .title01,.title02 {color:#fff;font-weight:bold;}
12 #DoorP{border:12px solid #eee;width:150px;padding:4px;background:#fff;}
13 h2{text-align:center;margin:0px;padding:0px;line-height:22px;}
14 .title01{width:100%;height:25px;background:#00ccff;cursor:pointer;}
15 .title02{width:100%;height:25px;background:#99cc00;cursor:pointer;}
16 .content{background:#eee;border-bottom:2px solid #fff;overflow:hidden;color:#666;padding-left:4px;padding-right:4px;line-height:18px;}
17 .content a:link,.content a:visited{color:#666666;text-decoration:none;}
18 .content a:hover{color:#FF6600;text-decoration:underline;}
19 </style>
20 <title></title>
21 </head>
22 
23 <body>
24 <div id="DoorP">
25   <h2>第一层信息</h2>
26   <div class="content">菜单一<br /></div>
27   <h2>第二层信息</h2>
28   <div class="content"><a href="#">子菜单</a><br /><a href="#">子菜单</a><br /><a href="#">子菜单</a><br /><a href="#">子菜单</a><br /><a href="#">子菜单</a><br /><a href="#">子菜单</a><br /><a href="#">子菜单</a><br /><a href="#">子菜单</a><br /></div>
29   <h2>第三层信息</h2>
30   <div class="content">菜单三<br />菜单三<br />菜单三<br />菜单三<br />菜单三<br />菜单三<br /></div>
31   <h2>第四层信息</h2>
32   <div class="content">子菜单<br />子菜单<br />子菜单<br />子菜单<br />子菜单<br />子菜单<br />子菜单<br />子菜单<br /></div>
33   <h2>第五层信息</h2>
34   <div class="content">子菜单<br />子菜单<br />子菜单<br />子菜单<br />子菜单<br />子菜单<br /></div>
35   <h2>第六层信息</h2>
36   <div class="content">子菜单<br />子菜单<br />子菜单<br />子菜单<br />子菜单<br />子菜单<br />子菜单<br />子菜单<br />子菜单<br
37 
38 /></div>
39 </div>
40 <script type="text/javascript">
41 var onum=0;// 设置初始打开的层序号
42 var closeState=new Array();
43 var ch=new Array();
44 function $(id){if(document.getElementByIdx(id)){return document.getElementByIdx(id);}else{alert("没有找到!")}}
45 function $tag(id,tagName){return $(id).getElementsByTagName_r(tagName)}
46 var Ds=$tag("DoorP","div");
47 var Ts=$tag("DoorP","h2");
48 if(Ds.length != Ts.length){alert("初始化失败!");}
49 function showMe(Cid,Oid){var h=parseInt(Ds[Cid].style.height);var h2=parseInt(Ds[Oid].style.height);var dH=ch[Oid];if(h>0){h=h-Math.ceil(h/3);Ds
50 
51 [Cid].style.height=h+"px";};if(h2<dH){h2=h2+Math.ceil((dH-h2)/3);Ds[Oid].style.height=h2+"px";};if(h<=0&&h2>=dH){clearTimeout(closeState[Cid]);return
52 
53 false;};closeState[Cid] = setTimeout("showMe("+Cid+","+Oid+")");}
54 for(var i=0;i<Ds.length;i++){
55   ch[i]=Ds[i].offsetHeight;
56   if(i==onum){Ds[i].style.height=ch[i]+"px";Ts[i].className="title01";}else{Ds[i].style.height="0px";Ts[i].className="title02";}
57   Ts[i].value=i;
58   Ts[i].onclick=function(){if(onum==this.value){return false;};
59    Ts[onum].className="title02";
60    Ts[this.value].className="title01";
61    for(var i=0;i<closeState.length;i++){clearTimeout(closeState[i]);}
62    showMe(onum,this.value);
63    onum=this.value;
64   }
65 }
66 </script>
67 </body>
68 </html>

 

posted @ 2013-07-24 10:51  殷跃杰  阅读(107)  评论(0编辑  收藏  举报