当前位置: 首页 > 图文教程 > 网页制作 > HTML/XHTML教程 > 一个简单的javascript菜单(4)

HTML/XHTML教程
Xhtml第11天:如何制作不用表格的菜单
Xhtml第3天:定义语言编码
Xhtml第2天:什么是名字空间
CSS滤镜之Wave属性
CSS滤镜之Chroma属性
(译)用CSS设计日历
CSS滤镜之Shadow属性
CSS滤镜之Glow属性
CSS滤镜之Mask属性
在网页中实现细线边框的两种方法
背景音乐是如何插入的?
CSS 标签属性/属性参考
弹出网页窗口全攻略(html/hta)
五彩缤纷建网页(1)
五彩缤纷建网页(2)色彩的基本知识
五彩缤纷建网页(4)背景与字体的搭配经验
五彩缤纷建网页(3)色彩的象征
精通 CSS 滤镜(四)
精通 CSS 滤镜(三)
XHTML代码规范

HTML/XHTML教程 中的 一个简单的javascript菜单(4)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-04   浏览: 63 ::
收藏到网摘: n/a


  //菜单条的按钮
  this.addMenuBarItem=function(ary,index){
   var item=menu.crtElement("button",menu.bar);
   item.value=ary[0];
   item.disabled=!ary;
   item.className=id+"_barItem";
   item.onmouseover=function(){
    if(menu.selectedIndex==-1){
     item.className=id+"_barItemHover";
    }
    else{
     menu.barItems[selectedIndex].className=id+"_barItem";
     item.className=id+"_barItemDown";
     menu.showMenu(index);
    }
    window.status=ary;
   }
   item.onmouseout=function(){
    if(menu.selectedIndex==-1)  item.className=id+"_barItem";
    window.status="";
   }
   item.onclick=function(){
    event.cancelBubble=true;
    if(menu.selectedIndex==-1){
     item.className=id+"_barItemDown";
     menu.showMenu(index);
    }
    else{
     menu.hideMenu();
     item.className=id+"_barItemHover";
    }
    menu.execute(ary);
    item.blur();
   }
   return item;
  }

  //显示子菜单
  this.showMenu=function(index){
   if(menu.selectedIndex!=-1) menu.pads[selectedIndex].style.display="none";
   menu.board.style.pixelLeft=menu.barItems[index].offsetLeft+2;
   //menu.board.style.pixelHeight="";
   if(menu.pads[index].rows.length>0) menu.board.style.display="";
   else menu.board.style.display="none";
   menu.pads[index].style.display="";
   menu.selectedIndex=index;
  }