惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
Visual Studio Blog
C
Cisco Blogs
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Scott Helme
Scott Helme
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
M
MIT News - Artificial intelligence
L
LINUX DO - 热门话题
I
InfoQ
GbyAI
GbyAI
NISL@THU
NISL@THU
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Engineering at Meta
Engineering at Meta
H
Hackread – Cybersecurity News, Data Breaches, AI and More
TaoSecurity Blog
TaoSecurity Blog
Simon Willison's Weblog
Simon Willison's Weblog
A
About on SuperTechFans
Spread Privacy
Spread Privacy
月光博客
月光博客
W
WeLiveSecurity
AWS News Blog
AWS News Blog
云风的 BLOG
云风的 BLOG
有赞技术团队
有赞技术团队
Security Latest
Security Latest
人人都是产品经理
人人都是产品经理
PCI Perspectives
PCI Perspectives
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Microsoft Azure Blog
Microsoft Azure Blog
Hugging Face - Blog
Hugging Face - Blog
S
SegmentFault 最新的问题
T
Troy Hunt's Blog
Martin Fowler
Martin Fowler
The Hacker News
The Hacker News
T
Tor Project blog
C
CERT Recently Published Vulnerability Notes
Apple Machine Learning Research
Apple Machine Learning Research
Stack Overflow Blog
Stack Overflow Blog
K
Kaspersky official blog
Cloudbric
Cloudbric
H
Help Net Security
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tailwind CSS Blog
D
DataBreaches.Net
Security Archives - TechRepublic
Security Archives - TechRepublic
T
Tenable Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
博客园 - Franky
L
LINUX DO - 最新话题
MyScale Blog
MyScale Blog

博客园 - H.Wong

Use Windows Live Writer Tool to post a Sina Blog. Music Radio Online 1.0.0.0 release-perview 继续更新 Music Radio Beta-Perview 1.0.0.0.(做了一个听音乐电台的东东.:>) NET 4 Feature Focus: Parallel Programming 利用java的开源组件JExcel创建无差异的Excel文件,并且导入到.net项目中去. 利用POI创建OpenOffice中的Excel文件 java:利用jexcelapi 创建Excel C#和硬件驱动交互编程<二> --东进语音卡项目例子. C#和硬件驱动交互编程<一> --东进语音卡项目例子. Nunit--the TDD Great Tools. [导入]Session做的购物车 [导入]C#面试的一些问题. [导入]适用于web2.0的js对话框 - H.Wong - 博客园 [导入]meta用法 [导入]前段時間做了一個168的sp接口,share代碼,用socket實現d. [导入]js 监视键盘操作 [导入]ServerVariables集合 [导入]存储过程-分隔符号-多条件查询 [导入]Sql Convert用法 [导入]WEB2.0中AJAX应用的简单探讨
javascript 无限级树形菜单.
H.Wong · 2008-06-30 · via 博客园 - H.Wong

很多的cms后台和shop后台的导航都很好看.
不过有时候在添加删除的时候很麻烦.本人也苦于这样.
嘿嘿本人不喜欢.net的treeview,总感觉静态的导航的话没有什么必要所以写了个树形.
js代码:

 1var list=new Array();
 2            list=[["","a0","aa1","target='blank' href='http://baidu.com/s?wd='"],["","a1","aa2","target='blank' href='http://baidu.com'"],["","a2","aa3","target='blank' href='http://baidu.com'"],["a0","2","bb","target='blank' href='http://baidu.com'"],["2","b2","bba","target='blank' href='http://baidu.com'"],["b2","b22","bbaaa","target='blank' href='http://baidu.com'"],["b2","b221","bbaaa","target='blank' href='http://baidu.com'"],["b2","b222","bbaaa","target='blank' href='http://baidu.com'"],["b2","b223","bbaaa","target='blank' href='http://baidu.com'"]];
 3        function CreateObjectNode(nodeName,id,className,text)
 4        {
 5            var obj=document.createElement(nodeName);
 6            obj.id=id;
 7            obj.className=className;
 8            obj.innerHTML=text;
 9            return obj;
10        }

11        
12        function CreateItem(oMenuList,NodeName,BoxID)
13        {
14            var list=new Array();
15            list=oMenuList;
16            var parentNode=document.getElementById(BoxID);
17            
18            var len=parseInt(list.length);
19            for(i=0;i<len;i++)
20            {
21                
22                if(list[i][0]==NodeName){
23                var topBoxID=list[i][1]+i+"Top";
24                var itemBoxID=list[i][1]+i+"Item";
25                var titleBoxID=list[i][1]+i+"Title";
26                    
27                    //create top-box
28                    if(!document.getElementById(titleBoxID))
29                    {
30                    var item=CreateObjectNode("div",topBoxID,"","");}

31
32                    //create title-box
33                    if(!document.getElementById(titleBoxID))
34                    {var itemObj=CreateObjectNode("div",titleBoxID,"","-<a "+list[i][3]+" onclick=\"CreateSingleMenu('"+list[i][1]+"','"+itemBoxID+"');\">"+list[i][2]+"</a>");
35                    item.appendChild(itemObj);}

36                    //create item-box
37                    if(!document.getElementById(itemBoxID))
38                    var itemObjItem=CreateObjectNode("div",itemBoxID,"","");
39                    //itemObj.onclick="CreateSingleMenu('"+list[i][1]+"','"+itemBoxID+"')";
40                    
41                     
42                     item.appendChild(itemObjItem);}

43                     
44                    parentNode.appendChild(item);
45                }

46            }

47        }

48        function CreateSingleMenu(NodeName,BoxID)
49        {
50        var child=document.getElementById(BoxID).childNodes;
51        for(i=0;i<child.length;i++)
52            {child[i].innerHTML="";document.getElementById(BoxID).removeChild(child[i])}
53        if(NodeName=="")
54        {document.getElementById(BoxID).innerHTML="<a onclick=\"CreateSingleMenu('','box');\">clean</a>";}
55            CreateItem(list,NodeName,BoxID)
56        }

57        CreateSingleMenu("","box");

使用:

 1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2<html xmlns="http://www.w3.org/1999/xhtml">
 3<head>
 4    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 5    <title>变色导航栏</title>
 6<script type="text/javascript" src="javascript/js.js" />
 7    <style type="text/css">
 8.nav{
 9    width:200px;
10    height:auto;
11    margin:0px;
12    top:0px;
13    background: #2F5F8E;
14}

15.nav dl{
16    cursor: auto;
17}

18div{padding-left:10px;}
19div a{cursor: hand;}
20.nav dl dt{
21    font: bold 14px "Times New Roman", Times, serif;
22    color: #333333;
23    text-transform: capitalize;
24    background:#CCC;
25    text-indent: 10px;
26    cursor: hand;
27}

28.cccBG{
29    background: #CCCCCC;
30}

31.fffBG{
32    background: #FFFFFF;
33}

34.nav dl dd{
35    font: 12px Arial, Helvetica, sans-serif;
36    color: #FFFFFF;
37    cursor: hand;
38}

39a:link {
40    text-decoration: none;
41}

42a:visited {
43    text-decoration: none;
44}

45a:hover {
46    text-decoration: none;
47    color: #993300;
48}

49a:active {
50    text-decoration: none;
51}

52</style>
53</head>
54<body>
55    <div id="box" class="nav">
56    </div>
57</body>
58</html>

简单的实现了.
假如配合xml使用那就更好了.
不过这个对于我来说够用了.
贴出来,大家有兴趣的就改吧改吧吧.