zoukankan      html  css  js  c++  java
  • javascript滑动菜单制作

         下面是用javascript制作的滑动菜单效果,其实在显示的页面就是只用了一个Label控件,HTML代码都是自动生成的。


    javascript的代码:

    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;

    }



    组织菜单的代码:
       菜单
  • 相关阅读:
    aspnet_Membership_SetPassword
    FlipView使用
    结构之法字符串及链表的探索编程之美第3章
    window和linux下svn的使用
    【算法导论第13章】红黑树
    【算法导论】第16章贪心算法
    【算法导论】第15章动态规划
    ubuntu11.04下myeclipse开发环境的搭建(jdk6+tomcat6+myeclipse8.0+mysql)
    【matlab】在vc6.0中调用matlab中的正态分布产生随机数
    gnome/gtk+开发环境搭建
  • 原文地址:https://www.cnblogs.com/ringwang/p/992094.html
Copyright © 2011-2022 走看看