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

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