请教各位大虾:
如何在一个类似与qq栏的下拉栏里展现一个树状的级联菜单呢?
如现有一个qq栏的下拉页面:test.html和一个树状的页面:test1.html,问题是如何把test.html里展示的单个页面的跳转变为test1.html里的树状下拉结构呢?其实就是要求把test1.html用qq栏给包起来,单击某个栏目才能看到某个树,而不是原来的某个单条信息的跳转连接!

解决方案 »

  1.   

    test.html代码如下:
    <SCRIPT>
    function showitem(id,name,target)
    {
    if(target==null || target.length==0)
    return ("<span class=smallFont><a href='#"+id+"' onclick='loadURL(\"" + id + "\")'>"+name+"</a></span><br>");
    else
    return ("<span class=smallFont><a target="+target+" href='"+id+"'>"+name+"</a></span><br>");
    }function switchoutlookBar(number)
    {
    var i = outlookbar.opentitle;
    outlookbar.opentitle=number;
    var id1,id2,id1b,id2b
    if (number!=i && outlooksmoothstat==0){
    if (number!=-1)
    {
    if (i==-1)
    {
    id2="blankdiv";
    id2b="blankdiv";}
    else{
    id2="outlookdiv"+i;
    id2b="outlookdivin"+i;
    document.all("outlooktitle"+i).style.border="1px solid navy";
    document.all("outlooktitle"+i).style.background="#4491be";
    document.all("outlooktitle"+i).style.color="white";
    document.all("outlooktitle"+i).style.textalign="center";
    }
    id1="outlookdiv"+number
    id1b="outlookdivin"+number
    document.all("outlooktitle"+number).style.border="1px solid navy";
    document.all("outlooktitle"+number).style.background="TEAL";
    document.all("outlooktitle"+number).style.color="WHITE";
    document.all("outlooktitle"+number).style.textalign="center";
    smoothout(id1,id2,id1b,id2b,0);
    }
    else
    {
    document.all("blankdiv").style.display="";
    document.all("blankdiv").sryle.height="100%";
    document.all("outlookdiv"+i).style.display="none";
    document.all("outlookdiv"+i).style.height="0%";
    document.all("outlooktitle"+i).style.border="1px solid navy";
    document.all("outlooktitle"+i).style.background="#4491be";
    document.all("outlooktitle"+i).style.color="white";
    document.all("outlooktitle"+i).style.textalign="center";
    }
    }

    }function smoothout(id1,id2,id1b,id2b,stat)
    {
    if(stat==0){
    tempinnertext1=document.all(id1b).innerHTML;
    tempinnertext2=document.all(id2b).innerHTML;
    document.all(id1b).innerHTML="";
    document.all(id2b).innerHTML="";
    outlooksmoothstat=1;
    document.all(id1b).style.overflow="hidden";
    document.all(id2b).style.overflow="hidden";
    document.all(id1).style.height="0%";
    document.all(id1).style.display="";
    setTimeout("smoothout('"+id1+"','"+id2+"','"+id1b+"','"+id2b+"',"+outlookbar.inc+")",outlookbar.timedalay);
    }
    else
    {
    stat+=outlookbar.inc;
    if (stat>100)
    stat=100;
    document.all(id1).style.height=stat+"%";
    document.all(id2).style.height=(100-stat)+"%";
    if (stat<100)
    setTimeout("smoothout('"+id1+"','"+id2+"','"+id1b+"','"+id2b+"',"+stat+")",outlookbar.timedalay);
    else
    {
    document.all(id1b).innerHTML=tempinnertext1;
    document.all(id2b).innerHTML=tempinnertext2;
    outlooksmoothstat=0;
    document.all(id1b).style.overflow="auto";
    document.all(id2).style.display="none";
    }
    }
    }function getOutLine()
    {
    outline="<table "+outlookbar.otherclass+">";
    for (i=0;i<(outlookbar.titlelist.length);i++)
    {
    outline+="<tr><td name=outlooktitle"+i+" id=outlooktitle"+i+" ";
    if (i!=outlookbar.opentitle)
    outline+=" nowrap align=center style='cursor:hand;background-color:#4491be;color:white;height:5;border:1 solid navy' ";
    else
    outline+=" nowrap align=center style='cursor:hand;background-color:#4491be;color:#6666b3;height:5;border:1 solid white' ";
    outline+=outlookbar.titlelist[i].otherclass
    outline+=" onclick='switchoutlookBar("+i+")'><span class=smallFont><b>";
    outline+=outlookbar.titlelist[i].title+"</b></span></td></tr>";
    outline+="<tr><td name=outlookdiv"+i+" valign=top align=center  id=outlookdiv"+i+" style='width:100%"
    if (i!=outlookbar.opentitle)
    outline+=";display:none;height:0%;";
    else
    outline+=";display:;height:100%;";
    outline+="'><div name=outlookdivin"+i+" id=outlookdivin"+i+" style='overflow:auto;width:100%;height:100%'>";
    outline+="<table " + outlookbar.currentclass + ">";
    for (j=0;j<outlookbar.itemlist[i].length;j++) {
    outline += "<tr><td align=center>"
    outline+=showitem(outlookbar.itemlist[i][j].key,outlookbar.itemlist[i][j].title,outlookbar.itemlist[i][j].target);
    }
    outline+="</table>"
    outline+="</div></td></tr>"
    }
    outline+="<tr><td name=blankdiv valign=top align=center  id=blankdiv style='height:100%;width:100%:"
    if (outlookbar.opentitle!=-1)
    outline+=";display:none;";
    else
    outline+=";display:;";
    outline+="'><div style='overflow:auto;width:100%;height:100%'>";
    outline+="</div></td></tr>"

    outline+="</table>"
    return outline}function show()
    {
    var outline;
    outline="<div id=outLookBarDiv name=outLookBarDiv style='width=100%;height:100%'>"
    outline+=outlookbar.getOutLine();
    outline+="</div>"
    document.write(outline);
    }function theitem(intitle,instate,inkey, target)
    {
    this.state=instate;
    this.otherclass=" nowrap ";
    this.key=inkey;
    this.title=intitle;
    this.target=target;
    }function addtitle(intitle)
    {
    outlookbar.itemlist[outlookbar.titlelist.length]=new Array();
    outlookbar.titlelist[outlookbar.titlelist.length]=new theitem(intitle,1,0);
    if (outlookbar.titlelist.length != (outlookbar.starttitle+1))
    outlookbar.titlelist[outlookbar.titlelist.length-1].otherclass=" nowrap align=center style='cursor:hand;background-color:#6666b3;color:white;height:5;border:1 solid navy' ";
    else
    outlookbar.titlelist[outlookbar.titlelist.length-1].otherclass=" nowrap align=center style='cursor:hand;background-color:#C1E0FF;color:#6666b3;height:5;border:1 solid white' ";
    return(outlookbar.titlelist.length-1);
    }function additem(intitle,parentid,inkey,target)
    {
    if (parentid>=0 && parentid<=outlookbar.titlelist.length)
    {
    outlookbar.itemlist[parentid][outlookbar.itemlist[parentid].length]=new theitem(intitle,2,inkey,target);
    outlookbar.itemlist[parentid][outlookbar.itemlist[parentid].length-1].otherclass=" nowrap align=left style='backgroundColor:blue;height:5' ";
    return(outlookbar.itemlist[parentid].length-1);
    }
    else
    additem=-1;
    }function outlook()
    {
    this.titlelist=new Array();
    this.itemlist=new Array();
    this.divstyle="style='height:100%;width:100%;overflow:auto' align=center";
    this.otherclass="border=0 cellspacing='0' cellpadding='0' style='height:100%;width:100%'valign=middle align=center ";
    this.currentclass="border=0 cellspacing='0' cellpadding='4' style='width:100%'valign=middle align=center ";
    this.addtitle=addtitle;
    this.additem=additem;
    this.starttitle=-1;
    this.show=show;
    this.getOutLine=getOutLine;
    this.opentitle=this.starttitle;
    this.reflesh=outreflesh;
    this.timedelay=50;
    this.inc=10;

    }function outreflesh()
    {
    document.all("outLookBarDiv").innerHTML=outlookbar.getOutLine();
    }function locatefold(foldname)
    {
    for (var i=0;i<outlookbar.titlelist.length;i++)
    if(foldname==outlookbar.titlelist[i].title)
    {
     outlookbar.starttitle=i;
     outlookbar.opentitle=i;
    }
    }
    var outlookbar=new outlook();
    var tempinnertext1,tempinnertext2,outlooksmoothstat
    outlooksmoothstat = 0;
    function loadURL(url) {
    window.parent.mainFrame.location = url;
    }</SCRIPT>
    <TABLE height=100% width=150>
    <TR>
    <TD>
    <SCRIPT>
    var t;
    t=outlookbar.addtitle('常用代码')
    outlookbar.additem('城市三字代码', t, 'forum.jsp?forum=107')
    outlookbar.additem('航空公司代码', t, 'forum.jsp?forum=106')t=outlookbar.addtitle('机票信息')
    //outlookbar.additem('报表浏览', t, 'report/CReportdetail.asp')
    outlookbar.additem('国际机票价格', t, 'search.jsp?forum=34')
    outlookbar.additem('国际机票价格<br>(附件)', t, 'search.jsp?forum=35')
    outlookbar.additem('国内机票价格', t, 'forum.jsp?forum=109')
    outlookbar.additem('级别管理',t, 'ClassGroupCreate.jsp')
    outlookbar.show()
    switchoutlookBar(1)
    </SCRIPT></TD>
    </TR>
    </TABLE>
      

  2.   

    test1.html代码如下:<html>
    <head>
    <title>无限级树状菜单Tree Menu (简装版)</title>
    <!-- 在一个国外体育网中“盗用”的js ,我作了些修改和添加了注析说明,感觉有点类CSDN的菜单,不过点击大类就展开的功能还没有加上,过几天有时间我再完善 -->
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta content="MSHTML 5.00.3502.5390" name=Generator >
    <style type=text/css>
    /* CSS 请自己再增加必要的选项 */
    a {font: normal 12px 宋体; color: black; text-decoration: none; }
    a:link {font: normal 12px 宋体; color: black; text-decoration: none; }
    a:visited {font: normal 12px 宋体; color: black; text-decoration: none; }
    a:hover {font: normal 12px 宋体; color: black; text-decoration: none; }
    .icoface { border: 1px solid black; width: 9px; height: 9px; overflow: hidden; font: normal 7px 宋体; line-height: 8px; text-align: center; cursor: default; }
    .line-hight { font: normal 8px 宋体; }
    </style>
    <script language=javascript>
    function Nba23() //定义树状菜单对象
    {
    this.start=function() //菜单开始,bTop表示是否为最外层。
    {
    document.writeln("<table cellpadding=1 cellspacing=0>");
    }
    this.end=function() //菜单结束
    {
    document.writeln("</table>");
    }
    this.addmenu=function(cText,cLink,bChild,bShow) //为菜单增加项,参数依次为:菜单文字、菜单链接、是否有子菜单、子菜单是否显示。
    {
    document.writeln("<tr><td><nobr><span class=icoface"+(bChild?" onclick=menuChange(this)":"")+">"
    +(bChild?(bShow?"-":"+"):"·")+"</span><span class=line-hight> </span><a href="+cLink+" >"+cText+"</a></nobr></td></tr>");
    }// 想让连接在新窗口中打开,则把上面的<a href="+cLink+" >改为:<a href="+cLink+" target=_blank>
    this.childStart=function(bShow) //子选项开始,bShow为是否显示
    {
    document.writeln("<tr style='display:"+(bShow?"block":"none")+"'><td>");
    document.writeln("<table cellpadding=1 cellspacing=0 style='margin-left:12px;'>");
    }
    this.childEnd=function() //子选项结束
    {
    document.writeln("</table>");
    document.writeln("</td></tr>");
    }
    }
    function menuChange(obj) //控制菜单显示/隐藏
    {
    obj=obj.parentNode.parentNode.parentNode;
    obj.nextSibling.style.display=(obj.nextSibling.style.display=='none'?'block':'none');
    obj.cells[0].childNodes[0].childNodes[0].innerText=(obj.nextSibling.style.display=='none'?'+':'-')
    }
    </script>
    </head>
    <body>
    <br>
    <a>无限级树形菜单,Make by csdn nba23 8/6/2003 </a>
    <br><br>
    <script language=javascript>
    //生成菜单开始
    var cmsNba23=new Nba23();
    cmsNba23.start();
    cmsNba23.addmenu("我的专家门诊","#url",1,0); //后面两个参数分别表示是否有子菜单、子菜单是否显示
    cmsNba23.childStart(0); //参数与上面最后一个参数一致,如上面若设为1, ,此行的参数就应该设为1,初始状态就为已伸展
    cmsNba23.addmenu("我的问题","#url",0);
    cmsNba23.addmenu("我参与问题","#url",0);
    cmsNba23.addmenu("我得分问题","#url",0);
    cmsNba23.addmenu("我的专家分","#url",0);
    cmsNba23.addmenu("我的收藏夹","#url",0);
    cmsNba23.addmenu("短消息","#url",0);
    cmsNba23.addmenu("维护FAQ列表","#url",0);
    cmsNba23.addmenu("我的信誉分变化记录","#url",0);
    cmsNba23.childEnd();
    cmsNba23.addmenu("WEB开发","#url",1,0) //后面两个参数分别表示是否有子菜单,子菜单是否显示
    cmsNba23.childStart(0); //参数与上面最后一个参数一致
    cmsNba23.addmenu("ASP","#url",0);
    cmsNba23.addmenu("Java JSP/Servlet/JavaBean ","#url",0);
    cmsNba23.addmenu("PHP","#url",0);
    cmsNba23.addmenu("JavaScript ","#url",0);
    cmsNba23.addmenu("CGI ","#url",0);
    cmsNba23.addmenu("XML/SOAP ","#url",0);
    cmsNba23.addmenu("HTML(CSS) ","#url",0);
    cmsNba23.addmenu("其它 ","#url",0);
    cmsNba23.childEnd();
    cmsNba23.addmenu("多媒体/设计","#url",1,1);
    cmsNba23.childStart(1); //参数与上面最后一个参数一致,同时为0则为隐藏,如上面若设为1,0 ,此行的参数就应该设为0,初始状态就为已收缩
    cmsNba23.addmenu("网页设计(Dreamweaver等)","#url",0);
    cmsNba23.addmenu("图象工具使用","#url",0);
    cmsNba23.addmenu("Flash流媒体 ","#url",0);
    cmsNba23.addmenu("多媒体设计(3DMaX, Maya等)","#url",0);
    cmsNba23.childEnd();
    cmsNba23.addmenu("其它","#url",1,0); //后面两个参数分别表示是否有子菜单、子菜单是否显示
    cmsNba23.childStart(0); //参数与上面最后一个参数一致
    cmsNba23.addmenu("子菜单一 (含)","#url",1,0);
    cmsNba23.childStart(0);
    cmsNba23.addmenu("子菜单一(1)","#url",0);
    cmsNba23.addmenu("子菜单一(2)","#url",0);
    cmsNba23.addmenu("子菜单一(3) (含)","#url",1,0);
    cmsNba23.childStart(0);
    cmsNba23.addmenu("子菜单一(3)(a)","#url",0);
    cmsNba23.addmenu("子菜单一(3)(b)","#url",0);
    cmsNba23.addmenu("子菜单一(3)(c)","#url",0);
    cmsNba23.childEnd();
    cmsNba23.childEnd();
    cmsNba23.addmenu("子菜单二","#url",0);
    cmsNba23.addmenu("子菜单三","#url",0);
    cmsNba23.addmenu("子菜单四","#url",0);
    cmsNba23.addmenu("子菜单五","#url",0);
    cmsNba23.addmenu("子菜单六","#url",0);
    cmsNba23.childEnd();
    cmsNba23.end();
    //结束生成菜单函数
    </script>
    </body>
    </html>