JS树型菜单

JS文件

------------------------------------- 

var isIE = true;
var imgUp = "images/arrowUp.gif" ;
var imgDn = "images/arrowDn.gif" ;
function expandIt( head, fExpandOnly )
{
 var bulletImg ;
 var allCol = "document." + ( isIE ? "all." : "" ) + head ;
 var parentDiv = eval( allCol + "Parent" );
 var childDiv  = eval( allCol + "Child" );
 if ( isIE )
 {
  if ( parentDiv )
   bulletImg = parentDiv.children( 0 ).children( 'imEx' );
  if ( childDiv )
  {
   if ( childDiv.style.display == "block" && (!fExpandOnly) )
   {
    childDiv.style.display = "none" ;
    if ( bulletImg )
     bulletImg.src = imgUp ;
   }
   else
   {
    childDiv.style.display = "block" ;
    if ( bulletImg )
     bulletImg.src = imgDn ;
   }
  }
 }
 else
 {
  if ( parentDiv )
   bulletImg = parentDiv.document.images[ 'imEx' ];
  if ( childDiv )
  {
   if ( childDiv.visibility == "hide" )
   {
    childDiv.visibility = "show" ;
    if ( bulletImg )
     bulletImg.src = imgDn ;
   }
   else if ( ! fExpandOnly )
   {
    childDiv.visibility = "hide";
    if ( bulletImg )
     bulletImg.src = imgUp ;
   }
  }
 }
 return false ; // cancels event
}

function doClick ( )
{
 el = event.srcElement;
 while ( el && el.tagName != "A" )
 {
  el = el.parentElement ;
 }
 if ( ! el ) return ;
 if ( el.target != "main" ) return ;
 hiliteSel( el ); 
}
var prevSel = null ;
function hiliteSel ( selLink )
{
 var selColor = "red" ;
 if ( prevSel )
 {
  prevSel.style.color = prevSel.prevColor ;
 }
 prevSel = selLink ;
 prevSel.prevColor = selLink.style.color ;
 selLink.style.color = selColor ;
}

function init() {
  document.onclick = doClick ;
  expandIt("head2");
  //hiliteSel(ttt);
//  parent.frames("Main").location.href = "/gtc/programMgr.html";
}

if ( screen.colorDepth > 8 )
{
// document.write( "<STYLE>BODY{background-image:url(/images/ai/tile_nav.jpg);}</STYLE>" );
}
var licenseID ='01-0006-0038-69648' ;
var pendingChanges =false ;


-------------------------------------------------------------------------------------

 

HTML文件

----------------


<HTML>
<HEAD>
<TITLE></TITLE>
<LINK REL=stylesheet HREF="script/toc.css" TYPE="text/css">
<SCRIPT LANGUAGE="JavaScript" src="script/AdminTree.js"></script>
<STYLE TYPE='text/css'>
.level1 {margin-left:30;}
.level2 {display:none;margin-left:38;}
</STYLE>
</HEAD>
<BODY οnlοad="init()" topmargin="0" leftmargin="0" rightmargin="0">
<DIV CLASS="level1" ID='head2Parent'>
 <A class=OUTDENT href="" οnclick='return expandIt("head2");'><IMG border=0 name=imEx  src="images/arrowUp.gif" id=ttt> 用户管理</a>
</DIV>

<DIV CLASS="level2" ID='head2Child'>
 <A href="addAdmin.jsp" id=ttt target=main οnclick="doClick()"><LI>增加管理员</LI></a>
 <A href="adminList.jsp" id=ttt target=main><LI>用户列表</LI></a>
 <A href="RoleManager.jsp" id=ttt target=main><LI>系统角色</LI></a>
</DIV>

<DIV CLASS="level1" ID='head3Parent'>
 <A class=OUTDENT href="" οnclick='return expandIt("head3");' id=ttt><IMG border=0 height=13 name=imEx  src="images/arrowUp.gif" width=17> 产品管理</a>
</DIV>

<DIV CLASS="level2" ID='head3Child'>
 
 <A href="Resource.jsp" id=ttt target=main><LI>产品列表</LI></a>
 <A href="ListServerResourceDir.jsp" id=ttt target=main><LI>产品搜索</LI></a>
</DIV>

<DIV CLASS="level1" ID='head4Parent'>
 <A class=OUTDENT href="" οnclick='return expandIt("head4");' id=ttt><IMG border=0 height=13 name=imEx  src="images/arrowUp.gif" width=17> 类别管理</a>
</DIV>

<DIV CLASS="level2" ID='head4Child'>
 <A href="Course.jsp" id=ttt target=main><LI>类别列表</LI></a>
 <A href="CourseValidate.jsp" id=ttt target=main><LI>类别AJAVX</LI></a>

</DIV>

<DIV CLASS="level1" ID='head6Parent'>
 <A class=OUTDENT href="" οnclick='return expandIt("head6");' id=ttt><IMG border=0 height=13 name=imEx  src="images/arrowUp.gif" width=17> 订单管理</a>
</DIV>

<DIV CLASS="level2" ID='head6Child'>
 <A href="News.jsp" id=ttt target=main><LI>订单列表</LI></a>
</DIV>

<DIV CLASS="level1" ID='head7Parent'>
 <A class=OUTDENT href="" οnclick='return expandIt("head7");' id=ttt><IMG border=0 height=13 name=imEx  src="images/arrowUp.gif" width=17> 组织结构</a>
</DIV>

<DIV CLASS="level2" ID='head7Child'>
 <A href="Applier.jsp" id=ttt target=main><LI>组织结构管理</LI></a>
</DIV>

<DIV CLASS="level1" ID='head8Parent'>
 <A class=OUTDENT href="" οnclick='return expandIt("head8");' id=ttt><IMG border=0 height=13 name=imEx  src="images/arrowUp.gif" width=17> 直播管理</a>
</DIV>

<DIV CLASS="level2" ID='head8Child'>
      <A href="Live.jsp" id=ttt target=main><LI>直播组织</LI></a>
      <A href="LiveWorkstation.jsp" id=ttt target=main><LI>直播工作站管理</LI></a>
</DIV>

</BODY>
</html>

------------------------------------------------------------------------------------

 

var myTree = null; function CreateTree() { myTree = new ECOTree('myTree','myTreeContainer'); myTree.config.colorStyle = ECOTree.CS_LEVEL; myTree.config.nodeFill = ECOTree.NF_FLAT; myTree.config.selectMode = ECOTree.SL_NONE; //是否允许给节点加链接,是否允许给节点加图片 myTree.config.useTarget = false; myTree.config.useImg = true;   //设置节点的大小和间隔 myTree.config.defaultNodeWidth = 95; myTree.config.defaultNodeHeight = 140; myTree.config.iSubtreeSeparation = 50; myTree.config.iSiblingSeparation = 15; myTree.config.iLevelSeparation = 30; //此处通过从数据库或其它地方读取节点信息,生成添加节点的代码 //参数前三位是必须的; //第一位是本节点id,第二位是父节点id、根节点的父节点为-1,第三位为节点文本; //第四位为节点上显示的图片/照片、图片放到img下并在数据库中记录名称即可,未设参数则取默认图片; //第五位为超链接、最好是访问统一程序传入本节点id; //第六、七位为节点的个性化宽、高。 myTree.add('01',-1,'总裁','./img/0.jpg','http://www.jq-school.com'); myTree.add('02','01','技术副总裁','./img/1.jpg'); myTree.add('03','01','总裁助理','./img/2.jpg','http://www.jq-school.com',95,130); myTree.add('04','01','分公司','./img/3.jpg','http://www.jq-school.com',95,130); myTree.add('0201','02','技术经理','./img/4.jpg','http://www.jq-school.com',95,130); myTree.add('0202','02','技术员','./img/5.jpg','http://www.jq-school.com',95,130); myTree.add('0301','03','秘书','./img/5.jpg','http://www.jq-school.com',95,130); myTree.add('0302','03','助理','./img/6.jpg','http://www.jq-school.com',95,130); myTree.add('0401','04','总经理','./img/6.jpg','http://www.jq-school.com',95,130); myTree.add('0402','04','财务','./img/7.jpg','http://www.jq-school.com',95,130); myTree.UpdateTree(); } 包含有例子和源码。
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值