acerbic coffee
走自己的路,让别人跑步
posts - 26,comments - 14,trackbacks - 0
      妈的  上面那段代码太长了,差点没弄死机,好了,闲话不多说。上面贴出的代码你不必去详细研究它,其实只要会用就可以了。现在讲解一些经常要用到的参数,以及要注意的事项,还有就是个人做好的一个列出多级下拉菜单的例子;
      上端代码中 其实你主要需要注意的地方就是下面这两段代码:

function Menu(label, mw, mh, fnt, fs, fclr, fhclr, bg, bgh, halgn, valgn, pad, space, to, sx, sy, srel, opq, vert, idt, aw, ah) 
{
    
this.version = "020320 [Menu; mm_menu.js]";
    
this.type = "Menu";
    
this.menuWidth = mw;
    
this.menuItemHeight = mh;
    
this.fontSize = fs;
    
this.fontWeight = "plain";
    
this.fontFamily = fnt;
    
this.fontColor = fclr;
    
this.fontColorHilite = fhclr;
    
this.bgColor = "#555555";
    
this.menuBorder = 1;
    
this.menuBgOpaque=opq;
    
this.menuItemBorder = 1;
    
this.menuItemIndent = idt;
    
this.menuItemBgColor = bg;
    
this.menuItemVAlign = valgn;
    
this.menuItemHAlign = halgn;
    
this.menuItemPadding = pad;
    
this.menuItemSpacing = space;
    
this.menuLiteBgColor = "#ffffff";
    
this.menuBorderBgColor = "#777777";
    
this.menuHiliteBgColor = bgh;
    
this.menuContainerBgColor = "#cccccc";
    
this.childMenuIcon = "arrows.gif";
    
this.submenuXOffset = sx;
    
this.submenuYOffset = sy;
    
this.submenuRelativeToItem = srel;
    
this.vertical = vert;
    
this.items = new Array();
    
this.actions = new Array();
    
this.childMenus = new Array();
    
this.hideOnMouseOut = true;
    
this.hideTimeout = to;
    
this.addMenuItem = addMenuItem;
    
this.writeMenus = writeMenus;
    
this.MM_showMenu = MM_showMenu;
    
this.onMenuItemOver = onMenuItemOver;
    
this.onMenuItemAction = onMenuItemAction;
    
this.hideMenu = hideMenu;
    
this.hideChildMenu = hideChildMenu;
    
if (!window.menus) window.menus = new Array();
    
this.label = " " + label;
    window.menus[
this.label] = this;
    window.menus[window.menus.length] 
= this;
    
if (!window.activeMenus) window.activeMenus = new Array();
}


function addMenuItem(label, action) {
    
this.items[this.items.length] = label;
    
this.actions[this.actions.length] = action;
}
Menu函数 不必多说,是定义一个js中所谓的对象,这段函数里考虑的就是它的参数,lable个人理解就是定义的父级菜单的描述(若为第一级菜单即根节点则此处填写root)mw就是菜单的宽度,mh当然就是菜单的高度了,fcrl,fhcrl,bg是颜色(具体是哪个颜色,笔者没仔细研究过)
      举个例子:
function mmLoadMenus() {
  
if (window.mm_menu_usermenu) return;
      window.mm_menu_usermenu 
= new Menu("root",118,18,"",12,"#000000","#FFFFFF","#DDDDDD","#7E87E9","center","middle",3,0,1000,-5,7,true,false,true,0,false,true);
    mm_menu_usermenu.addMenuItem(
"查看员工工作日志","location='chaxun.asp'");
  mm_menu_usermenu.addMenuItem(
"待加项目","location='gz/xmjhjd.htm'");
   mm_menu_usermenu.hideOnMouseOut
=true;
   mm_menu_usermenu.bgColor
='#555555';
   mm_menu_usermenu.menuBorder
=0;
   mm_menu_usermenu.menuLiteBgColor
='#FFFFFF';
   mm_menu_usermenu.menuBorderBgColor
='#777777';

mm_menu_usermenu.writeMenus();
}
   这里“查看员工工作日志”和 “待加项目”都是一级菜单,故填写"root" 后面的center与middle当然就是字体居中的意思,其他的项感觉照填就可以了(可以搜索,有专门介绍后面几个boolean意思的文章)
   好了 现在说addMenuItem的用法 上面的例子已经给出了用法,很显然她是添加菜单内容的函数,有两个参数,分别代表的意思是菜单内容,以及跳转的页面,当然这个跳转页面可以带参数!
posted on 2006-11-22 18:45 acerbic coffee 阅读(338) 评论(0)  编辑  收藏 所属分类: 个人笔记

只有注册用户登录后才能发表评论。


网站导航: