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

HTML/XHTML教程
HTML5之后W3C将制定无版本号的HTML
IE6必然灭亡的最新6个理由
网页制作教程:单独对IE6进行兼容
Firefox 3.6频繁崩溃的问题
HTML5的发展:微格式和相关的属性名称
Chrome最新4.0版本支持GreaseMonkey脚本
网页前端常见的攻击方式和预防攻击办法
HTML5标准将把互联网视频扔回到黑暗时代
靠我们自己的力量把IE6推向灭亡
近期热点:HTML5是否真的可以取代Flash
网页知识新手了解:网页设计的发展历史
TinyEditor:简洁且易用的html所见即所得编辑器
ANSI,Unicode,UTF-8网页编码的区别
HTML5实例:20个使用HTML5编写的网站
网页表单设计:主要行为与次要行为
HTML网页实例代码:简洁漂亮的跳转等待页面
经验分享:关于网页布局排版的流程问题
W3C发布7个HTML工作草案
HTML5 旨在解决 Web 中的交互
网页优化的最基础部分:HTML的优化

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


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