📄 menu.js
字号:
//Author: Younes Bouab////Date Released: 06-19-02 @ 8:50AM////Version 1.26: Supports Frames & solved the MAC OS 9.X 10 BUG in IE // Menu Centered Dynamiclly (see 'LEFT' variable in 'Config.js' file) ////Title: Menu Generator////Copyright: Younes Bouab 2002 ////Technical Support: HMenu_Support@SUPEReDITION.com////Support: SUPEReDITION.com////////////////////////////////////////////////DO NOT CHANGE ANYTHING IN THIS FILE!//"Config.js" is the file you can edit///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////Copyright (c) 2002 Younes Bouab (www.SUPEReDITION.com) Version 1.25////Experience the DHTML Menu - Get it at www.SUPEReDITION.com////***********************************************************************************// If you decide to use our menu, please support us by sending // whatever financial contribution you can afford to: ////// SUPEReDITION.com// 717, 23rd Street #2// Sacramento CA 95816 - USA////// PayPal Account: Billing@SUPEReDITION.com//// // Users that have sent a financial contribution, will be entitled to // 1 year of technical support by sending an email to HMenu_Support@SUPEReDITION.com// Please, specify the version of the menu used when requesting support. //// //***********************************************************************************////All copyright messages MUST STAY intact////Menu HomePage: http://www.superedition.com/Main.asp?Page=Tutorials&query=Javascript//////////////////////////////////////////////////////////////////////////////////////////*******************************************///Dreamweaver Show/Hide/Obj Layer functions/*******************************************/function showHideLayers() { var i,p,v,obj,args=showHideLayers.arguments; for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2]; if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; } obj.visibility=v; }}function findObj(n, d) { var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); if(!x && document.getElementById) x=document.getElementById(n); return x;}function changeProp(objName,x,theProp,theValue) { var obj = findObj(objName); if (obj && (theProp.indexOf("style.")==-1 || obj.style)) eval("obj."+theProp+"='"+theValue+"'");}function reloadPage(init) { if (init==true) with (navigator) { if ((appName=="Netscape")&&(parseInt(appVersion)==4)) { document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage; } } else if (innerWidth!=document.pgW || innerHeight!=document.pgH) {location.reload();}}reloadPage(true);/******************************************/// Initialize/******************************************///Menu ArrayMenu =new Array(); //Menu[x][0]=INDEX - Menu[x][1]=PARENT - Menu[x][2]=Text - Menu[x][3]=Image - Menu[x][4]=Roll Image - Menu[x][5]=URL var i=0;var ii=0; //used in validation of Menu Arrayvar MaxMenuIndex=0;//Default Layer Frame for IE and NS6.Xvar Layer="\"<div id='\"+IDLABEL+\"' class='CBORDER' Style='Position:absolute; visibility:\"+VISIBILITY+\"; left:\"+(LEFT+NS6X)+\"px; top:\"+(TOP+NS6X)+\"px; width:\"+(WIDTH+NS6X)+\"px; height:\"+(HEIGHT+NS6X)+\"px; background-color:\"+MyLayerColor+\"; z-index:\"+ZINDEX+\"; URL(\"+MyURL+\")' \"";var Layer_End="</div>";LAYER= new Array();//Menu string FOR EACH ITEMMOUSEOVEROUT=new Array();//HOLDS THE LAYERIDs that should have OnMouseOver && OnMouseOut for each menuTOPLEFT=new Array(); //holds Top and left measures for each menu itemParent_Children_ID=new Array();//Layers Variablesvar IDLABEL="";var VISIBILITY="visible"; //defaultvar ZINDEX=0;var MyURL="";//Position function variablesvar TopParent=TOP;var LeftParent=LEFT;var ORGWIDTH=WIDTH;Parent_Child_Count=new Array(); //Counts the children of each Main Menuvar Main_Parent_Count=0; //Counts the number of the Main menu //Validation VariableError=false; SortingError=false; var mytarget="";//NS CORRECTIONSvar NS_Table_Width_Corr=0;var NS_Table_Heigth_Corr=0;var NS6X=0; if(!document.all && document.getElementById) {NS6X=-2;} /******************************************///Add Menu item to Menu Array/******************************************/function AddMenu(ID, Parent_ID, Text, Image, RollImage, URL, TARGET){ //Validation var valid = "0123456789"; var temp; if(ID.length==0) {alert("The Menu #"+(ii+1)+" does not have an ID assigned"); Error=true;} //check if ID is composed else { //Checking if number for(var j=0;j<ID.length;j++) { temp=ID.substring(j,j+1); if(valid.indexOf(temp)==-1) {alert("The ID of the Menu #"+(ii+1)+" should be a number value"); Error=true;} } } if(Parent_ID.length==0) {alert("The Menu #"+(ii+1)+" does not have a Parent_ID assigned"); Error=true;} //check if Parent_ID is composed of only numbers and dashes "-" else { //Checking if number for(var j=0;j<Parent_ID.length;j++) { temp=Parent_ID.substring(j,j+1); if(valid.indexOf(temp)==-1) {alert("The Parent_ID of the Menu #"+(ii+1)+" should be a number value"); Error=true;} } } if(Text.length==0 && Image.length==0) {alert("The Menu #"+(ii+1)+" should have either an image or a text assigned"); Error=true;} ii++; Menu[i] = new Array(); if(!Error) { for (var j=0; j < 7 ;j++) { if (j==0) { Menu[i][0]=ID; } if (j==1) { Menu[i][1]=Parent_ID; } if (j==2) { Menu[i][2]=Text; } if (j==3) { Menu[i][3]=Image; } if (j==4) { Menu[i][4]=RollImage; } if (j==5) { Menu[i][5]=URL; } if (j==6) { Menu[i][6]=TARGET; } } i++; MaxMenuIndex = i; } //Reinitialze Error Value Error=false;}/******************************************///Build Menus/******************************************/function Build(){ //Browser Check NS4XCorrection() //Initilize Position Variables for (var j=0;j<MaxMenuIndex;j++) { TOPLEFT[j]=new Array(); Parent_Child_Count[j]=0; MOUSEOVEROUT[j]=new Array(); Parent_Children_ID[j]=new Array(); TOPLEFT[j][0]=0; TOPLEFT[j][1]=0; } //Sort and check menu for errors if(Sort==1) {Sorting();} if(!SortingError) { //Build CSS: Layer Border if (LayerBorderSize!="") {document.writeln("<Style type=\"text/css\">"); document.writeln(".CBORDER {"); document.writeln(" width:"+WIDTH+"px;"); document.writeln(" heigth:"+HEIGHT+"px;"); document.writeln(" border: "+LayerBorderStyle+" "+LayerBorderColor+" "+LayerBorderSize+"px;"); document.writeln("}\n</style>\n"); } document.writeln("<script language='javascript'>var clicked=0;</script>"); //Build each Menu for (i=0; i < MaxMenuIndex;i++) { //Calculates Main Positions, visibility, and determines ID CalcLayerVariables(i); //Global Properties var MyLayerColor=LayerColor; var MyLayerRollColor=LayerRollColor; //Parent Color if(Menu[i][0]==Menu[i][1]) { //BG ROLL Color if (Main_Parent_LayerColor!="" ) { MyLayerColor=Main_Parent_LayerColor; } } //Layer Code LAYER[i]=eval(Layer); } //Add samelevel mouse events SameLevelMouseEvents(); //Build for (var j=0;j<MaxMenuIndex;j++) { var MyFONT=FONT; var MyFONTCOLOR=FONTCOLOR; var MyFONTSIZE=FONTSIZE; var MyFONTSTYLE=FONTSTYLE; var MySTARTCHAR=START_CHAR; //Parent/Children FONT Properties if(Menu[j][0]==Menu[j][1]) { if(Main_Parent_FONT!="") { MyFONT=Main_Parent_FONT; } if(Main_Parent_FONTCOLOR!="") { MyFONTCOLOR=Main_Parent_FONTCOLOR; } if(Main_Parent_FONTSIZE!="") { MyFONTSIZE=Main_Parent_FONTSIZE; } if(Main_Parent_FONTSTYLE!="") { MyFONTSTYLE=Main_Parent_FONTSTYLE; } if(Main_Parent_START_CHAR!="") { MySTARTCHAR=Main_Parent_START_CHAR; } } var MOUSEOVERCODE=""; var MOUSEOUTCODE=""; for (var jj=0;jj<MaxMenuIndex;jj++) { if(MOUSEOVEROUT[j][jj]!=null) { MOUSEOVERCODE=MOUSEOVERCODE+"showHideLayers('"+MOUSEOVEROUT[j][jj]+"','','show');"; MOUSEOUTCODE=MOUSEOUTCODE+"showHideLayers('"+MOUSEOVEROUT[j][jj]+"','','hide');"; } else { MOUSEOVERCODE=MOUSEOVERCODE+"PathRoad("+j+",1)"; MOUSEOUTCODE=MOUSEOUTCODE+"PathRoad("+j+",0)"; break; } } //Linking the entire layer area mytarget=""; if(Menu[j][6]!=""){mytarget=Menu[j][6];} document.write(LAYER[j]+" onMouseOver=\""+MOUSEOVERCODE+"\" onMouseOut=\""+MOUSEOUTCODE+"\">"); var LINK=""; //display link if any and setup rollover image if any if(Menu[j][5]!="") {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -