主题:  怎样在像QQ折叠一样的菜单里加个滚动啊

gomyway

职务:普通成员
等级:1
金币:0.0
发贴:67
注册:2003/12/21 14:34:06
#12004/2/21 14:39:52
如题



gomyway

职务:普通成员
等级:1
金币:0.0
发贴:67
注册:2003/12/21 14:34:06
#22004/2/23 14:55:14

图片如下:

就是那个箭头啊,当菜单太多的时候就会实现滚动,怎么没人答我啊



psshanghai

职务:普通成员
等级:1
金币:0.0
发贴:11
注册:2004/2/24 15:15:23
#32004/2/24 15:16:57
网页特效代码:)

简单~~~

帮你找来~



psshanghai

职务:普通成员
等级:1
金币:0.0
发贴:11
注册:2004/2/24 15:15:23
#42004/2/24 15:20:03
脚本说明:
把如下代码加入<body>区域中
<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')

t=outlookbar.addtitle('航班查询')
outlookbar.additem('国内航班查询', t, 'forum.jsp?forum=108')

t=outlookbar.addtitle('酒店信息')
outlookbar.additem('酒店价格', t, 'forum.jsp?forum=137')

t=outlookbar.addtitle('其他信息')
outlookbar.additem('联系人', t, 'forum.jsp?forum=166')
outlookbar.additem('产品发布', t, 'forum.jsp?forum=36')
outlookbar.additem('其它产品<br>(签证等)', t, 'forum.jsp?forum=151')

t=outlookbar.addtitle('客户服务')
outlookbar.additem('客户服务园地', t, 'forum.jsp?forum=121')
outlookbar.additem('问题反馈', t, 'forum.jsp?forum=136')

t=outlookbar.addtitle('各类表格')
outlookbar.additem('Worldspan申请表', t, 'worldspan.jsp', "_blank"
                

outlookbar.show()
switchoutlookBar(1)
</SCRIPT></TD>
</TR>
</TABLE>



psshanghai

职务:普通成员
等级:1
金币:0.0
发贴:11
注册:2004/2/24 15:15:23
#52004/2/24 15:23:28
类似QQ的导航条

脚本说明:
把如下代码加入<body>区域中
<script language="javascript">
<!--
//该函数在调用过程中只需要在将要点击的单元格内的onclick事件中调用showme函数即可
//function showme(obj1, obj2)该函数主要为使点击的对象高亮度显示,并调用moveme函数,参数obj1为母体即<div>标签的id,obj2为点击对象本身
//function moveme(obj)该函数判断单元的移动,并调用相应的函数处理,obj参数为母体
//function moveup(obj,objtop)该函数使一个单元向上移动,参数obj为母体,objtop为母体的本身最高高度
//function movedown(obj,objbuttom)该函数使一个单元向下移动,参数obj为母体,objbuttom为母体的本身最低高度

var headHeight = 22;//每个标题的高度
var bodyHeight = 160;//母体高度
var objcount = 6;//项目的个数,要改变了项目的个数别忘了该这个东西
var step = 6;//移动速度(请确认可以被'bodyHeight-headHeight'整除,当前的设定可选速度为1,2,3,6,23,138)
var moving = false;//是否有移动的项目

function showme(obj1, obj2)
{
    //以下循环为改变标题的背景颜色
    if (moving)
        return;
    moving = true;
    for(i=0;i<document.all.tags("td".length;i++)
        if (document.all.tags("td"[i].className.indexOf('headtd') == 0)
            document.all.tags("td"[i].className = 'headtd1';
    obj2.className = 'headtd2';
    moveme(obj1);
}

function moveme(obj)
{
    idnumber = parseInt(obj.id.substr(4));
    objtop = headHeight * (idnumber - 1);
    objbuttom = bodyHeight + headHeight * (idnumber - 2);
    currenttop = parseInt(obj.style.top);
    if (currenttop >= objbuttom)
    {
        //检验出每一个应该向上移动的层
        countid = 1;
        for(i=0;i<document.all.tags("div".length;i++)
            if (document.all.tags("div"[i].id == 'item'+countid+'body')
            {
                obj = document.all.tags("div"[i];
                objtop = headHeight * (countid - 1);
                if (countid == idnumber)
                {
                    moveup(obj,objtop,false);
                    break;
                }
                else
                    moveup(obj,objtop,true);
                countid++;
            }
    }
    else if ((currenttop <= objtop) && (idnumber < objcount))
    {
        //检验出每一个应该向下移动的层
        idnumber++;
        countid = objcount;
        for(i=document.all.tags("div".length-1;i>=0;i--)
            if (document.all.tags("div"[i].id == 'item'+countid+'body')
            {
                obj = document.all.tags("div"[i];
                objbuttom = bodyHeight + headHeight * (countid - 2);
                if (countid == idnumber)
                {
                    movedown(obj,objbuttom,false);
                    break;
                }
                else
                    movedown(obj,objbuttom,true);
                countid--;
            }
    }
}

function moveup(obj,objtop,ismove)
{
    currenttop = parseInt(obj.style.top);
    if (currenttop > objtop)
    {
        obj.style.top = currenttop - step;
        setTimeout('moveup('+obj.id+','+objtop+','+ismove+')',1)
        return;
    }
    moving = ismove;
}

function movedown(obj,objbuttom,ismove)
{
    currenttop = parseInt(obj.style.top);
    if (currenttop < objbuttom)
    {
        obj.style.top = currenttop + step;
        setTimeout('movedown('+obj.id+','+objbuttom+','+ismove+')',1)
        return;
    }
    moving = ismove;
}
// -->
</script>
<style type="text/css">
<!--
.headtd1 { background: #00A4E1; border: 2px outset; border-color: #00BBFF #0077FF #0077FF #00BBFF; cursor: hand; font-size: 9pt}
.headtd2 { background: #20C1FF; border: 2px outset; border-color: #60D3FF #0077FF #0077FF #60D3FF; cursor: hand; font-size: 9pt}
.bodytd { background: #99CCFF; border: 2px outset; border-color: #B0D8FF #0077FF #0077FF #B0D8FF; font-size: 9pt}
-->
</style>
<!--改改这个div(mainboard)的height,加一个项目当然要把它的值加22了,减一个项目当然就是减22了//-->
<div id="mainboard" style="position:absolute; left:2px; top:2px; width:120px; height:270px; z-index:3; overflow: hidden; background: #0099FF;" onclick="">
<div id="item1body" style="position:absolute; left:0; top:0; width:120px; height:160px; z-index:1; overflow: hidden">
<table width="100%" border="0" height="100%" cellpadding="2" cellspacing="0">
<tr>
<td id="item1head" height="20" class="headtd2" onclick="showme(item1body,this)">
<div align="center">工作室</div>
</td>
</tr>
<tr>
<td class="bodytd">
<div align="center"><a href="http://www.jzzy.com">建站资源网</a></div>
</td>
</tr>
</table>
</div>
<div id="item2body" style="position:absolute; left:0px; top:160; width:120; height:160; z-index:2; overflow: hidden">
<table width="100%" border="0" height="100%" cellpadding="2" cellspacing="0">
<tr>
<td id="item2head" height="20" class="headtd1" onclick="showme(item2body,this)">
<div align="center">邮箱</div>
</td>
</tr>
<tr>
<td class="bodytd">
<div align="center"><a href="mailto:webmaster@jzzy.com">发信给我哟</a></div>
</td>
</tr>
</table>
<p class="headtd1"> </p>
</div>
<div id="item3body" style="position:absolute; left:0; top:182; width:120px; height:160; z-index:3">
<table width="100%" border="0" height="100%" cellpadding="2" cellspacing="0">
<tr>
<td id="item3head" height="20" class="headtd1" onclick="showme(item3body,this)">
<div align="center">Q Q</div>
</td>
</tr>
<tr>
<td class="bodytd">
<div align="center">37146743</div>
</td>
</tr>
</table>
</div>
<div id="item4body" style="position:absolute; left:0; top:204; width:120px; height:160; z-index:4; overflow: hidden">
<table width="100%" border="0" height="100%" cellpadding="2" cellspacing="0">
<tr>
<td id="item4head" height="20" class="headtd1" onclick="showme(item4body,this)">
<div align="center">朋友</div>
</td>
</tr>
<tr>
<td class="bodytd">
<div align="center">
<p>小一、旁腾<br>
</p>
</div>
</td>
</tr>
</table>
</div>
<div id="item5body" style="position:absolute; left:0; top:226; width:120px; height:160; z-index:4; overflow: hidden">
<table width="100%" border="0" height="100%" cellpadding="2" cellspacing="0">
<tr>
<td id="item5head" height="20" class="headtd1" onclick="showme(item5body,this)">
<div align="center">陌生人</div>
</td>
</tr>
<tr>
<td class="bodytd">
<div align="center">
<p>小虎<br>
AAP<br>
<br>
小伙伴<br>
小一</p>
</div>
</td>
</tr>
</table>
</div>
<!--如果要添加一个子项目请拷贝一份下面的代码并放于后面。干什么,不要拷贝我了,是下面的//-->
<div id="item6body" style="position:absolute; left:0; top:248; width:120px; height:160; z-index:4; overflow: hidden">
<table width="100%" border="0" height="100%" cellpadding="2" cellspacing="0">
<tr>
<td id="item6head" height="20" class="headtd1" onclick="showme(item6body,this)">
<div align="center">版本号</div>
</td>
</tr>
<tr>
<td class="bodytd">
<div align="center">
<p>封锁了移动过<br>
程中的点击事件<br>
这样不会出现抖<br>
动现象了。
</div>
</td>
</tr>
</table>
</div>
<!--哎哎,别往下拷贝了,到我得上面为止了,拷贝到代码放到我后面吧
        哦,对了别忘了改几个id呀,div的id,td的id,还有onclick事件中的对象id
        id的规则是div中item+数字+body。td中item+数字+head
        还有div的style中的top值呀,是多少,上面这个div的top加上22就是了
        别忘了按照body下的提示改改mainboard的height呀。还有给教本中的objcount数量改为你现在项目的个数
        别傻了,快点行动吧,要不赶不上饭点了//-->
</div>
</body>
</html>