??????媽的? 上面那段代碼太長(zhǎng)了,差點(diǎn)沒(méi)弄死機(jī),好了,閑話不多說(shuō)。上面貼出的代碼你不必去詳細(xì)研究它,其實(shí)只要會(huì)用就可以了。現(xiàn)在講解一些經(jīng)常要用到的參數(shù),以及要注意的事項(xiàng),還有就是個(gè)人做好的一個(gè)列出多級(jí)下拉菜單的例子;
??????上端代碼中 其實(shí)你主要需要注意的地方就是下面這兩段代碼:
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函數(shù) 不必多說(shuō),是定義一個(gè)js中所謂的對(duì)象,這段函數(shù)里考慮的就是它的參數(shù),lable個(gè)人理解就是定義的父級(jí)菜單的描述(若為第一級(jí)菜單即根節(jié)點(diǎn)則此處填寫root)mw就是菜單的寬度,mh當(dāng)然就是菜單的高度了,fcrl,fhcrl,bg是顏色(具體是哪個(gè)顏色,筆者沒(méi)仔細(xì)研究過(guò))
??????舉個(gè)例子:

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("待加項(xiàng)目","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();
}???這里“查看員工工作日志”和 “待加項(xiàng)目”都是一級(jí)菜單,故填寫"root" 后面的center與middle當(dāng)然就是字體居中的意思,其他的項(xiàng)感覺(jué)照填就可以了(可以搜索,有專門介紹后面幾個(gè)boolean意思的文章)
???好了 現(xiàn)在說(shuō)addMenuItem的用法 上面的例子已經(jīng)給出了用法,很顯然她是添加菜單內(nèi)容的函數(shù),有兩個(gè)參數(shù),分別代表的意思是菜單內(nèi)容,以及跳轉(zhuǎn)的頁(yè)面,當(dāng)然這個(gè)跳轉(zhuǎn)頁(yè)面可以帶參數(shù)!
posted on 2006-11-22 18:45
acerbic coffee 閱讀(349)
評(píng)論(0) 編輯 收藏 所屬分類:
個(gè)人筆記