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

HTML/XHTML教程
CSS样式表设计的十条技巧
什么样的界面算是好界面-7个案例
CSS+JS实现的选项卡效果
用CSS设计高体验的表单显示效果示例
利用css和js实现firefox和IE都支持的页面局部打印
针对各种版本的浏览器隐藏CSS的九大技巧
Div+CSS布局入门教程
在DIV+CSS排版中新闻列表的制作方法
实践DIV+CSS网页布局入门指南
HTML中meta详解
有关HTML代码的另类应用技巧
彻底弄懂CSS盒子模式(DIV布局)
页面制作人员的修练之道
注意:HTML文件也能格式化硬盘
小技巧:让广告代码不再影响你的网页加载速度
进阶:彻底弄懂CSS盒子模式之二
彻底弄懂CSS盒子模式之三
详解css定位与定位应用
ASP生成静态Html文件技术杂谈
CSS的倡导者:学习CSS的10大理由

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-04   浏览: 39 ::
收藏到网摘: 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>