http://community.csdn.net/Expert/topic/4075/4075636.xml?temp=.9896051这个实现 ,稍微有点复杂。 你可以参考一下。

解决方案 »

  1.   

    var mimgpath="../../images/treeimg";
    var mfonts="style=\"text-decoration:none;font-family: Verdana; font-size: 8pt; color: #000000; \"";
    var movercolor="#0000FF";
    var mnormalcolor="#000000";
    var NC6=(navigator.userAgent.indexOf("Netscape6")>0)?true:false;
    var IE=(document.all)?true:false;
    function mOver(id) {
    if (IE) {eval(id).style.color=movercolor; } 
    else if(NC6){ document.getElementById(id).style.color=movercolor;}
    }
    function mOut(id) {
    if (IE) {eval(id).style.color=mnormalcolor; } 
    else if(NC6){ document.getElementById(id).style.color=mnormalcolor;}
    }function mFolderExpand($1,$2,pic) {
    if (IE) { mExpandIE($1,$2,pic) } 
    else if(NC6){ mExpandNC($1,$2,pic) }
    }function mExpandIE($1,$2,pic) {
    Expanda = eval($1 + "a");
    Expanda.blur()
    ExpandChild = eval($1 + "Child");
        if ($2 != "top") { 
    ExpandTree = eval($1 + "Tree");
    ExpandFolder = eval($1 + "Folder");
    }
    if (ExpandChild.style.display == "none") {
    ExpandChild.style.display = "block";
            if ($2 != "top") { 
                if ($2 == "last") { ExpandTree.src = mimgpath+"/Lminus.gif"; }
    else { ExpandTree.src = mimgpath+"/Tminus.gif"; }
    ExpandFolder.src = mimgpath+"/openfolder"+pic+".gif";
    }
    else { mmTree.src = mimgpath+"/topopen1.gif"; }
    }else{
    ExpandChild.style.display = "none";
            if ($2 != "top") { 
            if ($2 == "last") { ExpandTree.src = mimgpath+"/Lplus.gif"; }
    else { ExpandTree.src = mimgpath+"/Tplus.gif"; }
    ExpandFolder.src = mimgpath+"/folder"+pic+".gif";
    }
    else { mmTree.src = mimgpath+"/top1.gif"; }
    }
    }
    function mExpandNC($1,$2,pic) {
    Expanda = document.getElementById($1 + "a");
    Expanda.blur()
    ExpandChild = document.getElementById($1 + "Child");
        if ($2 != "top") { 
    ExpandTree = document.getElementById($1 + "Tree");
    ExpandFolder = document.getElementById($1 + "Folder");
    }
    if (ExpandChild.style.display == "none") {
    ExpandChild.style.display = "block";
            if ($2 != "top") { 
                if ($2 == "last") { ExpandTree.src = mimgpath+"/Lminus.gif"; }
    else { ExpandTree.src = mimgpath+"/Tminus.gif"; }
    ExpandFolder.src = mimgpath+"/openfolder"+pic+".gif";
    }
    else { document.getElementById("mmTree").src = mimgpath+"/topopen1.gif"; }
    }else{
    ExpandChild.style.display = "none";
            if ($2 != "top") { 
            if ($2 == "last") { ExpandTree.src = mimgpath+"/Lplus.gif"; }
    else { ExpandTree.src = mimgpath+"/Tplus.gif"; }
    ExpandFolder.src = mimgpath+"/folder"+pic+".gif";
    }
    else {document.getElementById("mmTree").src = mimgpath+"/top1.gif"; }
    }
    }
      

  2.   

    with(document){
    write("<div ID=\"mmParent\"><a ID=\"mma\" href=\"#\" style=\"text-decoration:none;font-family: Verdana; font-size: 8pt; color: #000000; font-weight: bold; \" onClick=\"mFolderExpand('mm','top',null)\">");
    write("<img ID=\"mmTree\" src=\""+mimgpath+"/topopen1.gif\" style=\"margin-right: 5\" align=\"absmiddle\" border=\"0\">");
    write("<font ID=\"mTitle0\" onmouseover=\"mOver('mTitle0')\" onmouseout=\"mOut('mTitle0')\">后台数据管理</font></a></div>");
    write("<div ID=\"mmChild\"><div ID=\"mm1Parent\"><a ID=\"mm1a\" "+mfonts+" onClick=\"mFolderExpand('mm1',null,'1')\" title=\"公司信息管理\">");
    write("<img ID=\"mm1Tree\" src=\""+mimgpath+"/Tplus.gif\" align=\"absmiddle\" border=\"0\"><img ID=\"mm1Folder\" src=\""+mimgpath+"/folder1.gif\" style=\"margin-right: 5\" align=\"absmiddle\" border=\"0\"><font ID=\"mTitle1\" onmouseover=\"mOver('mTitle1')\" onmouseout=\"mOut('mTitle1')\">公司信息管理</font></a>");
    write("</div>");
    write("<div ID=\"mm1Child\" style=\"display:none;\">");
    write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/T.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"company_resource.jsp\" "+mfonts+" title=\"可以对公司的概况,文化,资质/荣誉,组织机构,业绩,合作伙伴进行修改操作。\"><font ID=\"mTitle2\" onmouseover=\"mOver('mTitle2')\" onmouseout=\"mOut('mTitle2')\">公司资讯</font></a><br>");
    write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/T.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"company_query.jsp?actionType=queryCompany\" "+mfonts+" title=\"所有与公司相关的信息列表,包括:总公司信息,分公司信息等。\"><font ID=\"mTitle3\" onmouseover=\"mOver('mTitle3')\" onmouseout=\"mOut('mTitle3')\">公司列表</font></a><br>");
    write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/T.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"CompanyRefAction.action?actionType=initialize\" "+mfonts+" title=\"公司之间的关系管理,例如:总公司:大唐科技,子公司:北京分公司,上海分公司。\"><font ID=\"mTitle4\" onmouseover=\"mOver('mTitle4')\" onmouseout=\"mOut('mTitle4')\">公司关系</font></a><br>");
    write("</div>");write("<div ID=\"mm5Parent\"><a ID=\"mm5a\" "+mfonts+" onClick=\"mFolderExpand('mm5',null,'1')\" title=\"产品信息管理\">");
    write("<img ID=\"mm5Tree\" src=\""+mimgpath+"/Tplus.gif\" align=\"absmiddle\" border=\"0\"><img ID=\"mm5Folder\" src=\""+mimgpath+"/folder1.gif\" style=\"margin-right: 5\" align=\"absmiddle\" border=\"0\"><font ID=\"mTitle16\" onmouseover=\"mOver('mTitle16')\" onmouseout=\"mOut('mTitle16')\">产品信息管理</font></a>");
    write("</div>");
    write("<div ID=\"mm5Child\" style=\"display:none;\">");
    write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/T.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"ProductManger.jsp\" "+mfonts+" title=\"公司产品类别的管理,例如:CPU,内存都属于电脑硬件类别。\"><font ID=\"mTitle5\" onmouseover=\"mOver('mTitle5')\" onmouseout=\"mOut('mTitle5')\">产品类别列表</font></a><br>");
    write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/T.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"productAction.action?actionType=initialize\" "+mfonts+" title=\"所有产品列表,包括:产品的名称,图片路径等。\"><font ID=\"mTitle6\" onmouseover=\"mOver('mTitle6')\" onmouseout=\"mOut('mTitle6')\">产品列表</font></a><br>");
    write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/T.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"Pim.jsp\" "+mfonts+" title=\"所有产品信息的列表,就是每个产品自己特征或者属性。例如:电脑的属性:显示器(菲利浦),鼠标(明基),键盘(微软)等。\"><font ID=\"mTitle7\" onmouseover=\"mOver('mTitle7')\" onmouseout=\"mOut('mTitle7')\">产品信息列表</font></a><br>");
    write("</div>");
      

  3.   

    write("<div ID=\"mm6Parent\"><a ID=\"mm6a\" "+mfonts+" onClick=\"mFolderExpand('mm6','null','1')\" title=\"对网站的一些基础信息的管理,例如:新闻,行业信息,用户反馈等。\">");
    write("<img ID=\"mm6Tree\" src=\""+mimgpath+"/Tplus.gif\" align=\"absmiddle\" border=\"0\"><img ID=\"mm6Folder\" src=\""+mimgpath+"/folder1.gif\" style=\"margin-right: 5\" align=\"absmiddle\" border=\"0\"><font ID=\"mTitle18\" onmouseover=\"mOver('mTitle18')\" onmouseout=\"mOut('mTitle18')\">基础信息管理</font></a>");
    write("</div>");
    write("<div ID=\"mm6Child\" style=\"display:none;\">");
    write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/T.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"news.jsp\" "+mfonts+" title=\"网站最新新闻管理\"><font ID=\"mTitle19\" onmouseover=\"mOver('mTitle19')\" onmouseout=\"mOut('mTitle19')\">新闻</font></a><br>");
    write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/T.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"FriendLink.jsp\" "+mfonts+" title=\"友情连接管理\"><font ID=\"mTitle13\" onmouseover=\"mOver('mTitle13')\" onmouseout=\"mOut('mTitle13')\">友情连接</font></a><br>");
    write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/T.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"black.html\" "+mfonts+" title=\"行业信息管理\"><font ID=\"mTitle14\" onmouseover=\"mOver('mTitle14')\" onmouseout=\"mOut('mTitle14')\">行业信息</font></a><br>");
    write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/T.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"ResUpload.jsp\" "+mfonts+" title=\"上传您需要的资料\"><font ID=\"mTitle15\" onmouseover=\"mOver('mTitle15')\" onmouseout=\"mOut('mTitle15')\">资料上传</font></a><br>");
    write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/T.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"black.html\" "+mfonts+" title=\"用户反馈信息管理\"><font ID=\"mTitle17\" onmouseover=\"mOver('mTitle17')\" onmouseout=\"mOut('mTitle17')\">用户反馈</font></a><br>");
    write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/T.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"OnlinePurchase.jsp\" "+mfonts+" title=\"对客户订单的管理\"><font ID=\"mTitle25\" onmouseover=\"mOver('mTitle25')\" onmouseout=\"mOut('mTitle25')\">客户订单</font></a><br>");
    write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/T.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"black.html\" "+mfonts+" title=\"对招聘动态的管理\"><font ID=\"mTitle26\" onmouseover=\"mOver('mTitle26')\" onmouseout=\"mOut('mTitle26')\">招聘动态</font></a><br>");
    write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/T.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"black.html\" "+mfonts+" title=\"采购平台\"><font ID=\"mTitle27\" onmouseover=\"mOver('mTitle27')\" onmouseout=\"mOut('mTitle27')\">采购平台</font></a><br>");
    write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/T.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"VendorCooperate.jsp\" "+mfonts+" title=\"经销商合作\"><font ID=\"mTitle28\" onmouseover=\"mOver('mTitle28')\" onmouseout=\"mOut('mTitle28')\">经销商合作</font></a><br>");
    write("<img src=\""+mimgpath+"/I.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/T.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"NetworkService.jsp\" "+mfonts+" title=\"服务网络管理\"><font ID=\"mTitle20\" onmouseover=\"mOver('mTitle20')\" onmouseout=\"mOut('mTitle20')\">服务网络</font></a><br>");
    write("</div>");write("<div ID=\"mm7Parent\"><a ID=\"mm7a\" "+mfonts+" onClick=\"mFolderExpand('mm7','last','1')\" title=\"网站后台管理员和网站注册用户的信息管理。\">");
    write("<img ID=\"mm7Tree\" src=\""+mimgpath+"/Lplus.gif\" align=\"absmiddle\" border=\"0\"><img ID=\"mm7Folder\" src=\""+mimgpath+"/folder1.gif\" style=\"margin-right: 5\" align=\"absmiddle\" border=\"0\"><font ID=\"mTitle21\" onmouseover=\"mOver('mTitle21')\" onmouseout=\"mOut('mTitle21')\">用户信息管理</font></a>");
    write("</div>");
    write("<div ID=\"mm7Child\" style=\"display:none;\">");
    write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/T.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"PersonAction.do?actionType=showQueryPerson\" "+mfonts+" title=\"用户信息管理\"><font ID=\"mTitle22\" onmouseover=\"mOver('mTitle22')\" onmouseout=\"mOut('mTitle22')\">用户信息列表</font></a><br>");
    write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/T.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"ResumeAction.do?actionType=showQueryResume\" "+mfonts+" title=\"简历信息管理\"><font ID=\"mTitle23\" onmouseover=\"mOver('mTitle23')\" onmouseout=\"mOut('mTitle23')\">简历信息列表</font></a><br>");
    write("<img src=\""+mimgpath+"/white.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/L.gif\" align=\"absmiddle\" width=\"19\" height=\"20\" border=\"0\"><img src=\""+mimgpath+"/item4.gif\" align=\"absmiddle\" style=\"margin-right: 5\"><a target=\"main_right\" href=\"change_pwd.jsp\" "+mfonts+" title=\"修改已经登陆用户的密码\"><font ID=\"mTitle24\" onmouseover=\"mOver('mTitle24')\" onmouseout=\"mOut('mTitle24')\">修改密码</font></a><br>");
    write("</div>");}