首页>互联网>语言脚本>JavaScript>正文

一个简单的javascript菜单(5)

日 期:2006-10-22     来 源:    阅 读:
  


  //隐藏子菜单
  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[2]==null) return;
   if(ary[1]=="js") { eval(ary[2]); menu.hideMenu(); }
   else if(ary[1]==null || ary[1].toLowerCase=="_self") location.href=ary[2];
   else{ var x=window.open(ary[2],ary[1]); 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>



上一篇:一个强制弹出窗口的javascript类:ForceWindow   下一篇:javascript技巧:让网页自动穿上外套
收藏本文到:
digg this! 添加到del.icio.us bbmao网络收藏夹 添加到365key 我顶 添加到bolaa 推荐到奇客发现 添加到新浪vivi 添加到google书签 添加到yahoo+
查看全部JavaScript内容  
 用户名: 新注册) 密码: 匿名发表 评论(0条)
 评论内容:(不能超过250字,不支持HTML或代码,只能发表纯文字,请自觉遵守互联网相关政策法规。)
[an error occurred while processing this directive]
合作伙伴: 电脑综合 8vv8娱乐榜

关于扑虎 | 扑虎新闻 | 联系扑虎 | 广告服务 | 招贤纳士

Copyright @ 2006-2007 poohu.com. All Right Reserved 陕ICP备06010975号