<!DOCTYPE HTML PUBLIC //WC//DTD HTML Transitional//EN>
<html>
<head>
<title>AgetimeMenu Demo</title>
<meta httpequiv=ContentType content=text/html; charset=gb>
<style>
agetime_bar{
position:absolute;top:px;left:px;height:px;width:%;border:px outset;backgroundcolor:RGB();zindex:;
}
agetime_barItem{
width:px;height:px;border:px solid RGB();textalign:left;paddingleft:px;
background:RGB();color:#;fontsize:pt;
}
agetime_barItemDown{
width:px;height:px;border:px inset RGB();textalign:left;paddingleft:px;
background:#FFF;color:#;fontsize:pt;
}
agetime_barItemHover{
width:px;height:px;border: outset;textalign:left;paddingleft:px;
background:#FFF;color:#;fontsize:pt;
}
agetime_pad{
cursor:default;fontsize:pt;width:%;
}
agetime_padItem{
width:%;height:px;border:px solid RGB();textalign:left;paddingleft:px;
background:RGB();color:#;fontsize:pt;
}
agetime_padItemFalse{
paddingleft:px;fontsize:pt; color:#;
}
agetime_padItemFalseHover{
paddingleft:px;fontsize:pt; color:#;backgroundcolor:#;
}
agetime_padItemHover{
width:%;height:px;textalign:left;paddingleft:px;
backgroundcolor:#;color:#FFFFFF;fontsize:pt;
}
agetime_padItemDown{
width:%;height:px;textalign:left;paddingleft:px;border:px inset;
backgroundcolor:#CC;color:#FFFFFF;fontsize:pt;
}
agetime_hr{
border:px inset;
}
agetime_board{
backgroundcolor:RGB();border:px outset;
}
</style>
</head>
<body>
<script language=javascript>
var menu = agetimeMenu(agetime
[
[
[文件nullnulltrue打开文件]//显示文字方法命令状态状栏显示文字
[打开nullnullfalse打开文件]
[]
[你好jsalert(Hello)true一声问候]
[新窗口ABCabout:blanktrue弹出ABC窗口]
[空白nullabout:blanktrue在当前窗口显示空白页]
]
[
[编辑nullnullfalse打开文件]
[撤消nullnulltrue打开文件]
[重做nullnulltrue打开文件]
]
[
[文件jsalert(无子菜单)true打开文件]
]
]
);
//方法为js时命令则为javascript语句为非js值时命令则是一个URL而打开这个URL的目标位置则是方法所指定的窗口;
//[你好jsalert(Hello)true一声问候];
//显示文字为是按钮是一个分隔符;
function agetimeMenu(idarray){
var menu=this;
menupad=null; //装载各个子菜单
menubarItems=[];//菜单条的各位按钮
menupads=[]; //每个子菜单为一个table存放于menupad上;
menuselectedIndex=;//菜单条选中按钮的索引值
menuboard=null;//子菜单面板
//建立菜单条
thiscrtMenuBar=function(){
var len=arraylength;
menubar = documentbodyappendChild(documentcreateElement(div));
menubarclassName=id+_bar;
for(var i=;i<len;i++){
menubarItems[i]=menuaddMenuBarItem(array[i][]i);
menuaddMenuPad(array[i]i);
}
}
//子菜单
thisaddMenuPad=function(aryindex){
var len=arylength;
var pad=menucrtElement(tablemenupad);
padcellSpacing=;padcellPadding=;
padclassName=id+_pad;
padstyledisplay=none;
for(var i=;i<len;i++){
var Row=padinsertRow(i);
menuaddMenuPadItem(ary[i]Row);
}
menupads[index]=pad;
}
//各子菜单按钮
thisaddMenuPadItem=function(aryRow){
var Cell=RowinsertCell();
if(ary[]!=){
CellinnerText=ary[];
if(ary[]){//有效状态;
CellclassName=id+_padItem;
Cellonmouseover=function(){
CellclassName=id+_padItemHover;
windowstatus=ary[];
}
Cellonmouseout=function(){
CellclassName=id+_padItem;
windowstatus=;
}
Cellonmousedown=function(){ CellclassName=id+_padItemDown; }
Cellonmouseup=function(){
CellclassName=id+_padItemHover;
menuhideMenu();
menuexecute(ary);
}
}
else{//按钮无效;
CellclassName=id+_padItemFalse;
Cellonmouseover=function(){
CellclassName=id+_padItemFalseHover;
windowstatus=ary[];
}
Cellonmouseout=function(){
CellclassName=id+_padItemFalse;
windowstatus=;
}
}
}
else{
var hr=menucrtElement(hrCell);
hrclassName=id+_hr;
}
Cellonclick=function(){
eventcancelBubble=true;
}
}
//菜单条的按钮
thisaddMenuBarItem=function(aryindex){
var item=menucrtElement(buttonmenubar);
itemvalue=ary[];
itemdisabled=!ary[];
itemclassName=id+_barItem;
itemonmouseover=function(){
if(menuselectedIndex==){
itemclassName=id+_barItemHover;
}
else{
menubarItems[selectedIndex]className=id+_barItem;
itemclassName=id+_barItemDown;
menushowMenu(index);
}
windowstatus=ary[];
}
itemonmouseout=function(){
if(menuselectedIndex==)itemclassName=id+_barItem;
windowstatus=;
}
itemonclick=function(){
eventcancelBubble=true;
if(menuselectedIndex==){
itemclassName=id+_barItemDown;
menushowMenu(index);
}
else{
menuhideMenu();
itemclassName=id+_barItemHover;
}
menuexecute(ary);
itemblur();
}
return item;
}
//显示子菜单
thisshowMenu=function(index){
if(menuselectedIndex!=) menupads[selectedIndex]styledisplay=none;
menuboardstylepixelLeft=menubarItems[index]offsetLeft+;
//menuboardstylepixelHeight=;
if(menupads[index]rowslength>) menuboardstyledisplay=;
else menuboardstyledisplay=none;
menupads[index]styledisplay=;
menuselectedIndex=index;
}
//隐藏子菜单
thishideMenu=function(){
if(menuselectedIndex==) return;
menubarItems[menuselectedIndex]className=id+_barItem;
menupads[selectedIndex]styledisplay=none;
menuselectedIndex=;
menuboardstyledisplay=none;
}
//执行菜单命令;
thisexecute=function(ary){
if(ary[]==null) return;
if(ary[]==js) { eval(ary[]); menuhideMenu(); }
else if(ary[]==null || ary[]toLowerCase==_self) locationhref=ary[];
else{ var x=windowopen(ary[]ary[]); xfocus(); }
}
//建立子菜单的显示面板
thiscrtMenuBoard=function(){
documentwrite(
<div id=+id+_board style=position:absolute;width:px;height:px;left:px;top:px;backgroundcolor:#;zindex:;display:none;>+
<div style=position:absolute;width:%;height:%;left:px;top:px;>+
<iframe id=+id+_frame name=+id+_frame width=% height=% frameborder= scrolling=no></iframe>+
</div>+
<div id=+id+_pad style=position:absolute;width:%;height:%;left:px;top:px;></div>+
</div>
);
menuboard=documentgetElementById(id+_board);
menupad=documentgetElementById(id+_pad);
menupadclassName=id+_board;
menupadonselectstart=function(){ return false;}
}
//增加对像的一个子元素
thiscrtElement=function(elp){
return pappendChild(documentcreateElement(el));
}
//安装菜单;
thissetup=function(){
menucrtMenuBoard();
menucrtMenuBar();
documentattachEvent(onclickmenuhideMenu);
}
menusetup();
}
</script>
</body>
</html>