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

HTML/XHTML教程
网页设计师如何应对客户无理要求
打开网页速度提升的简单而有效的方法
让IE8启动IE7兼容模式的简便代码
HTML的sub,sup标签制作电子商务网站中的价格
IE9关键字:硬件渲染,新的JS引擎,CSS,标准
让IE支持HTML5办法
HTML教程:HTML的10个表格相关标记
HTML教程:网页页面切换的各种效果
网页制作掌握的最常用的HTML标记
应该怎样把HTML结构化
XHTML基础教程:xhtml的块级标记
网页页面实现自动刷新的3种代码
网页制作教程:TD也可以溢出隐藏显示
网页设计教程:TabIndex元素
微软:IE9与HTML 5的关系
HTML设备标识符可以让用户使用网页与摄像头等硬件设备打交道
HTML5和CSS3的一些新变化
超级链接标记A的TARGET属性详解
语义化的网页:XHTML语义化标记
理论知识:PSD模板切成HTML的正确操作

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


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