无限级树形菜单

< html >

< head >
< title > 无限级树形菜单 title >
< style >
#A1 td 
{ vertical-align: top; }
#A1 td.bj 
{ font-family: Wingdings; color: #FF9933; text-align: center; }
#A1 td.bj , #A1 td.kg 
{ width: 24; }
#A1 a:link , #A1 a: visited 
{ color: #cc0080; text-decoration: none; }
#A1 a:hover 
{ color: #0ff080; text-decoration: none; }
style >

< script  language ="JavaScript" >
//作者:海浪

function treeClass(id)
{
this.id = id;
this.HTMLdata = "";

this.start = function()   //菜单开始
{
  
this.HTMLdata += ''+this.id+'">'
}


this.end = function()   //菜单结束
{
  
this.HTMLdata += ''
}


this.m_start = function(name,tt)   //菜单组开始
{
  
this.HTMLdata += ''+(tt==1?Ƈ'')+''
  
this.HTMLdata += ''+name+''
  
this.HTMLdata += ''
  
this.HTMLdata += ''+(tt==1?'block':'none')+'">'
  
this.HTMLdata += ' '
  
this.HTMLdata += ''
  
this.HTMLdata += ''
}


this.m_end = function()   //菜单组结束
{
  
this.HTMLdata += ''
}


this.add_Sub = function(name,url,kj)   //添加菜单项
{
  
this.HTMLdata += '2'
  
this.HTMLdata += ''+kj+'" href="'+url+'">'+name+''
  
this.HTMLdata += ''
}


this.print = function()   //输出菜单 
{
  document.write(
this.HTMLdata);
}

}


function zgmm()
{
var ero = event.srcElement.parentElement.previousSibling;
var mo = event.srcElement.parentElement.parentElement.nextSibling;
mo.style.display 
= (mo.style.display=="none")?"block":"none";
ero.innerHTML 
= (mo.style.display=="none")?"0":"1";
}

script >
head >

< body >

< script  language ="JavaScript" >
//   说明:
//
   菜单组开始,m_start(name,tt); name为菜单组名称,tt为1菜单组初始时展开,为0不展开
//
   菜单组结束:m_end();
//
   添加菜单项:add_Sub("菜单项名称","url地址","框架名");

var tObj = new treeClass("A1")
tObj.start();
tObj.m_start(
"菜单组名称",1);
  tObj.m_start(
"菜单组名称",0);
  tObj.add_Sub(
"菜单项名称","#","_blank");
  tObj.m_start(
"菜单组名称",0);
    tObj.m_start(
"菜单组名称",0);
      tObj.add_Sub(
"菜单项名称,这项太太太太太太太太太太太太太太太太太太太太太太太太太太太太太太太太太太太太太太太太太太太太太太长了,一行显示不了","#","_blank");
      tObj.add_Sub(
"菜单项名称","#","_blank");
    tObj.m_end();
    tObj.m_start(
"菜单组名称",0);
      tObj.add_Sub(
"菜单项名称","#","_blank");
    tObj.m_end();
  tObj.m_end();
  tObj.add_Sub(
"菜单项名称","#","_blank");
  tObj.add_Sub(
"菜单项名称","#","_blank");
  tObj.m_end();
  tObj.m_start(
"菜单组名称",0);
  tObj.add_Sub(
"菜单项名称","#","_blank");
  tObj.add_Sub(
"菜单项名称","#","_blank");
  tObj.m_end();
  tObj.add_Sub(
"菜单项名称","#","_blank");
  tObj.add_Sub(
"菜单项名称","#","_blank");
  tObj.add_Sub(
"菜单项名称","#","_blank");
tObj.m_end();
tObj.m_start(
"菜单组名称",0);
  tObj.add_Sub(
"菜单项名称","#","_blank");
  tObj.add_Sub(
"菜单项名称","#","_blank");
  tObj.add_Sub(
"菜单项名称","#","_blank");
tObj.m_end();
tObj.add_Sub(
"菜单项名称","#","_blank");
tObj.add_Sub(
"菜单项名称","#","_blank");
tObj.m_start(
"菜单组名称",0);
  tObj.add_Sub(
"菜单项名称","#","_blank");
  tObj.add_Sub(
"菜单项名称","#","_blank");
  tObj.m_start(
"菜单组名称",0);
  tObj.add_Sub(
"菜单项名称","#","_blank");
  tObj.m_end();
tObj.m_end();
tObj.add_Sub(
"菜单项名称","#","_blank");
tObj.add_Sub(
"菜单项名称","#","_blank");
tObj.end();
tObj.print();

script >


body >

html >
 

你可能感兴趣的:(javascript)