dtree的下載與使用,dtree下載使用
dtree是一個由JavaScript編寫成的樹形菜單組件,免費並且開源。
dtree有以下優點:
- Unlimited number of levels(無限分級)- Can be used with or without frames(可用於架構或非架構頁面)- Remembers the state of the tree between pages(在不同頁面之間可記住目前狀態)- Possible to have as many trees as you like on a page(可以得到你想要數量的樹型)- All major browsers suported(支援的瀏覽器)Internet Explorer 5+ Netscape 6+ Opera 7+ Mozilla- Generates XHTML 1.0 strict validated output(嚴格支援XHTML 1.0)- Alternative images for each node(每個節點用圖片代替)
dtree的:
http://www.destroydrop.com/javascripts/tree/
下載dtree.zip,解壓目錄如下:
img檔案夾: 包含樹形菜單顯示需要的表徵圖api.html : dtree協助文檔dtree.css: 樹形菜單的樣式dtree.js : js代碼都在其中example01.html:樹形菜單一實例
需要引用檔案的檔案
<link rel="StyleSheet" href="dtree.css" type="text/css" />
<script type="text/javascript" src="dtree.js"></script>
使用樣本如下:
<div class="dtree">
<p><a href="javascript: d.openAll();">open all</a> | <a href="javascript: d.closeAll();">close all</a></p>
<script type="text/javascript">
<!--
d = new dTree('d');
d.add(0,-1,'My example tree');
d.add(1,0,'Node 1','example01.html');
d.add(2,0,'Node 2','example01.html');
d.add(3,1,'Node 1.1','example01.html');
d.add(4,0,'Node 3','example01.html');
d.add(5,3,'Node 1.1.1','example01.html');
d.add(6,5,'Node 1.1.1.1','example01.html');
d.add(7,0,'Node 4','example01.html');
d.add(8,1,'Node 1.2','example01.html');
d.add(9,0,'My Pictures','example01.html','Pictures I\'ve taken over the years','','','img/imgfolder.gif');
d.add(10,9,'The trip to Iceland','example01.html','Pictures of Gullfoss and Geysir');
d.add(11,9,'Mom\'s birthday','example01.html');
d.add(12,0,'Recycle Bin','example01.html','','','img/trash.gif');
document.write(d);
//-->
</script>
</div>
運行效果如下: