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

HTML/XHTML教程
你应该知道的CSS的十八个技巧
初学者很好的参考:HTML标签详尽讲解
学习网页标准制作技术之CSS相关基础知识
学习网页标准制作网页之CSS混合布局应用
HTML基础教程:详细学习常用HTML标签的语义
网页设计基础:基本的页面设计元素布局比例
网页制作基础:图像文件的路径知识
html基础系列教程Ⅰ:从p开始,循序渐进
html基础系列教程Ⅱ:丰富段落里的标签
html基础系列教程Ⅲ:用途相似的标签
html基础系列教程Ⅳ:链接与文本标签们
html基础系列教程Ⅴ:美化段落文本Ⅰ
html基础系列教程Ⅵ:美化段落文本Ⅱ
Web标准知识:(X)HTML Strict 下的嵌套规则
Web标准知识:语义与样式无关
Web标准知识:DIV不是万能膏药
web标准知识:当标题不能显示完整的时候
web标准知识:以图换字的几个方法及思路
CSS教程:legend标签设定宽度的技巧
html基础:常用小技巧几例

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


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



  //隐藏子菜单
  this.hideMenu=function(){
   if(menu.selectedIndex==-1) return;
   menu.barItems[menu.selectedIndex].className=id+"_barItem";
   menu.pads[selectedIndex].style.display="none";
   menu.selectedIndex=-1;
   menu.board.style.display="none";
  }

  //执行菜单命令;
  this.execute=function(ary){
   if(ary==null) return;
   if(ary=="js") { eval(ary); menu.hideMenu(); }
   else if(ary==null || ary.toLowerCase=="_self") location.href=ary;
   else{ var x=window.open(ary,ary); x.focus(); }
  }

  //建立子菜单的显示面板
  this.crtMenuBoard=function(){
   document.write(
    "<div id='"+id+"_board' style='position:absolute;width:160px;height:10px;left:0px;top:20px;background-color:#666666;z-index:99;display:none;'>"+
     "<div style='position:absolute;width:100%;height:100%;left:0px;top:0px;'>"+
      "<iframe id='"+id+"_frame' name='"+id+"_frame' width='100%' height='100%' frameborder='0' scrolling='no'></iframe>"+
     "</div>"+
     "<div id='"+id+"_pad' style='position:absolute;width:100%;height:100%;left:0px;top:0px;'></div>"+
    "</div>"
   );
   menu.board=document.getElementById(id+"_board");
   menu.pad=document.getElementById(id+"_pad");
   menu.pad.className=id+"_board";
   menu.pad.onselectstart=function(){ return false;}
  }

  //增加对像的一个子元素
  this.crtElement=function(el,p){
   return p.appendChild(document.createElement(el));
  }

  //安装菜单;
  this.setup=function(){
   menu.crtMenuBoard();
   menu.crtMenuBar();
   document.attachEvent("onclick",menu.hideMenu);
  }

  menu.setup();
 }
</script>
</body>
</html>