??????媽的? 上面那段代碼太長了,差點沒弄死機,好了,閑話不多說。上面貼出的代碼你不必去詳細研究它,其實只要會用就可以了。現在講解一些經常要用到的參數,以及要注意的事項,還有就是個人做好的一個列出多級下拉菜單的例子;
??????上端代碼中 其實你主要需要注意的地方就是下面這兩段代碼:
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 閱讀(349)
評論(0) 編輯 收藏 所屬分類:
個人筆記