一个简单的javascript菜单

时间:2010-04-16 12:18:09  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:; charset=gb2312"><style>.agetime_bar{ position:absolute;top:0px;left:0px;height:22px;width:100%;border:1px outset;background-color:RGB(212,208,200);z-index:98;}.agetime_barItem{ width:60px;height:20px;border:1px solid RGB(212,208,200);text-align:left;padding-left:10px; background:RGB(212,208,200);co...
  正文:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>AgetimeMenu Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style>
.agetime_bar{
 position:absolute;top:0px;left:0px;height:22px;width:100%;border:1px outset;background-color:RGB(212,208,200);z-index:98;
}
.agetime_barItem{
 width:60px;height:20px;border:1px solid RGB(212,208,200);text-align:left;padding-left:10px;
 background:RGB(212,208,200);color:#000000;font-size:9pt;
}
.agetime_barItemDown{
 width:60px;height:20px;border:1px inset RGB(212,208,200);text-align:left;padding-left:10px;
 background:#F0F0F0;color:#000000;font-size:9pt;
}
.agetime_barItemHover{
 width:60px;height:20px;border:1 outset;text-align:left;padding-left:10px;
 background:#F0F0F0;color:#000000;font-size:9pt;
}
.agetime_pad{
 cursor:default;font-size:9pt;width:100%;
}
.agetime_padItem{
 width:100%;height:18px;border:1px solid RGB(212,208,200);text-align:left;padding-left:10px;
 background:RGB(212,208,200);color:#000000;font-size:9pt;
}
.agetime_padItemFalse{
 padding-left:10px;font-size:9pt; color:#808080;
}
.agetime_padItemFalseHover{
 padding-left:10px;font-size:9pt; color:#808080;background-color:#333366;
}
.agetime_padItemHover{
 width:100%;height:18px;text-align:left;padding-left:10px;
 background-color:#333366;color:#FFFFFF;font-size:9pt;
}
.agetime_padItemDown{
 width:100%;height:18px;text-align:left;padding-left:10px;border:1px inset;
 background-color:#9999CC;color:#FFFFFF;font-size:9pt;
}
.agetime_hr{
 border:1px inset;
}
.agetime_board{
 background-color:RGB(212,208,200);border:2px outset;
}
</style>
</head>
<body>
<script language="JavaScript">
var menu = agetimeMenu("agetime",
 [
  [
  ["文件",null,null,true,"打开文件"], //显示文字,方法,命令,状态,状栏显示文字
  ["打开",null,null,false,"打开文件"],
  ["--"],
  ["你好","js","alert('Hello')",true,"一声问候"],
  ["新窗口","ABC","about:blank",true,"弹出ABC窗口"],
  ["空白",null,"about:blank",true,"在当前窗口显示空白页"]
  ],
  [
  ["编辑",null,null,false,"打开文件"],
  ["撤消",null,null,true,"打开文件"],
  ["重做",null,null,true,"打开文件"]
  ],
  [
  ["文件","js","alert('无子菜单')",true,"打开文件"]
  ]
 ]
);
//方法为"js"时,命令则为javascript语句,为非"js"值时,命令则是一个URL,而打开这个URL的目标位置则是方法所指定的窗口;
//["你好","js","alert('Hello'),true,"一声问候"];
//显示文字为"--"是按钮是一个分隔符;

function agetimeMenu(id,array){
 var menu=this;
 menu.pad=null;   //装载各个子菜单
 menu.barItems=[];  //菜单条的各位按钮
 menu.pads=[];   //每个子菜单为一个table存放于menu.pad上;
 menu.selectedIndex=-1; //菜单条选中按钮的索引值
 menu.board=null;  //子菜单面板

 //建立菜单条
 this.crtMenuBar=function(){
  var len=array.length;
  menu.bar = document.body.appendChild(document.createElement('div'));
  menu.bar.className=id+"_bar";
  for(var i=0;i<len;i++){
  menu.barItems[i]=menu.addMenuBarItem(array[i][0],i);
  menu.addMenuPad(array[i],i);
  }
 }

 //子菜单
 this.addMenuPad=function(ary,index){
  var len=ary.length; 《一个简单的javascript菜单》由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Programming/JavaScript/13685.html


关键字:

关于《一个简单的javascript菜单》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td