新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     W3CHINA.ORG讨论区     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论.NET,C#,ASP,VB技术
    [返回] 中文XML论坛 - 专业的XML技术讨论区计算机技术与应用『 Dot NET,C#,ASP,VB 』 → 我有个avaScript的下来菜单 如何在一张页面里多次使用它 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 4750 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 我有个avaScript的下来菜单 如何在一张页面里多次使用它 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     zx147 帅哥哟,离线,有人找我吗?
      
      
      等级:大一新生
      文章:2
      积分:59
      门派:XML.ORG.CN
      注册:2007/7/13

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给zx147发送一个短消息 把zx147加入好友 查看zx147的个人资料 搜索zx147在『 Dot NET,C#,ASP,VB 』的所有贴子 引用回复这个贴子 回复这个贴子 查看zx147的博客楼主
    发贴心情 我有个avaScript的下来菜单 如何在一张页面里多次使用它

    我有个avaScript的下来菜单 如何在一张页面里多次使用它?
    放进一个页面不同位置的时候 有冲突,,该怎么改??
    求大虾们帮帮忙
    下面是那个菜单的代码
    <html>
    <head>
    <title>QQ菜单</title>
    <meta http-equiv='Content-Type' content='text/html; charset=gb2312'>
    <script language='JavaScript'>
    var headHeight = 22;var bodyHeight = 202;var objcount = 3;var step = 20;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>
    </script>
    <style type='text/css'>
    .headtd1 {  background: #ADADAD; border: 2px outset; border-color: #D8D8D8 #FFFFFF #FFFFFF #D8D8D8; cursor: hand; font-size: 9pt}.headtd2 {  background: #CCCCCC; border: 2px outset; border-color: #FFFFFF #FFFFFF #FFFFFF #FFFFFF; cursor: hand; font-size: 9pt}.bodytd  {  background: #BBBFCE; border: 2px outset; border-color: #FFFFFF #FFFFFF #FFFFFF #FFFFFF; font-size: 9pt}
    </style>
    </head>
    <body bgcolor='#FFFFFF' text='#000000'>
    <div id='mainboard' style='position:absolute; left:2px; top:2px; width:120px; height:246px; z-index:1; overflow: hidden; background: #BBBFCE;'>
    <div id='item1body' style='position:absolute; left:0; top:0; width:120px; height:202px; z-index:2; 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)' align='center'>菜单1</td></tr><tr><td class='bodytd' align='center'>test</td></tr></table></div><div id='item2body' style='position:absolute; left:0; top:202; width:120px; height:202px; z-index:3; 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)' align='center'>菜单2</td></tr><tr><td class='bodytd' align='center'>test</td></tr></table></div><div id='item3body' style='position:absolute; left:0; top:224; width:120px; height:202px; z-index:4; overflow: hidden'><table width='100%' border='0' height='100%' cellpadding='2' cellspacing='0'><tr><td id='item3head' height='20' class='headtd1' onclick='showme(item3body,this)' align='center'>菜单3</td></tr><tr><td class='bodytd' align='center'>test</td></tr></table></div></body></html>

       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2007/7/16 15:00:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 Dot NET,C#,ASP,VB 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/4/29 2:18:02

    本主题贴数1,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    63.477ms