我用过的一个,别人写的js,导入网页就行
/*
Author:fason
Date:2003-8-16
Email:[email protected]
*/
var icon=['/etsc/images/close.gif','/etsc/images/open.gif','/etsc/images/node.gif']
var img=[]
for(i=0;i<icon.length;i++){
img[i]=new Image()
img[i].src=icon[i]
}function tree(obj,target,selectOne){
this.obj=obj
this.target=target
this.node=[];
this.single=selectOne?true:false
this.LightObj=null
this.html="<style>.deeptree{padding:10px}\n.node{background-color:transparent;font-size:12px;font-family:Verdana;color:#000000;padding:4 2 4 0}\n"
this.html+=".node img{border:0;}\n"
this.html+=".node a{text-decoration:none;color:#000000;cursor:default}\n.node a:hover{text-decoration:underline}\n.node a.light{background-color:highlight;color:highlighttext}</style>"
}tree.prototype.add=function(id,pid,txt,link){
this.node[this.node.length]=[id,pid,txt,link]
}tree.prototype.draw=function(n){
var i;
for(i=0;i<this.node.length;i++){
if(this.node[i][1]==n){
if(this.isFolder(i)){
this.html+="<div class='node'><nobr><img width='13' height='13' id='img"+i+"' src='"+img[0].src+"' align='absmiddle' onclick='"+this.obj+".expand(this,"+i+")'> <a href='"+(this.node[i][3]?this.node[i][3]:'javascript:void(0)')+"' target='"+(this.target?this.target:'')+"' onclick='"+this.obj+".Light(this)' title='"+this.node[i][2]+"'>"+this.node[i][2]+"</a></nobr></div><div style='padding-left:10;display:none' id='child"+i+"'>"
this.draw(this.node[i][0])
this.html+="</div>"
}
else this.html+="<div class='node' style='padding-left:0'><nobr><img src='"+img[2].src+"'  align='absmiddle'> <a href='"+(this.node[i][3]?this.node[i][3]:'javascript:void(0)')+"' target='"+(this.target?this.target:'')+"' onclick='"+this.obj+".Light(this)' title='"+this.node[i][2]+"'>"+this.node[i][2]+"</a></nobr></div>"
}
}
}tree.prototype.expand=function(o,n){
if(this.single){
for(var i=0;i<this.node.length;i++)
if((this.node[i][1]==this.node[n][1])&&this.isFolder(i)){
var m=document.getElementById('img'+i)
var c=document.getElementById('child'+i).style
m.src=m==o?(c.display==''?img[0].src:img[1].src):img[0].src
c.display=m==o?(c.display==''?'none':''):'none'
}
}
else{
var c=document.getElementById('child'+n).style
o.src=c.display==''?img[0].src:img[1].src
c.display=c.display==''?'none':''
}
}tree.prototype.isFolder=function(n){
var num=0;
for(var i=0;i<this.node.length;i++)
if(this.node[i][1]==this.node[n][0])num++
if(num>0)return true;
return false
}tree.prototype.expandAll=function(flag){
for(var i=0;i<this.node.length;i++)
if(this.isFolder(i)){
var m=document.getElementById('img'+i)
var c=document.getElementById('child'+i).style
m.src=flag?img[1].src:img[0].src
c.display=flag?'':'none'
}
}
tree.prototype.Light=function(o){
if(this.LightObj==null)this.LightObj=o
this.LightObj.className=''
o.className='light'
this.LightObj=o
o.blur()
}tree.prototype.toString=function(){
this.draw(-1);
return this.html
}