| <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; var pad=menu.crtElement("table",menu.pad); pad.cellSpacing=1; pad.cellPadding=0; pad.className=id+"_pad"; |