Guest toddhill Posted April 2, 2009 Report Share Posted April 2, 2009 Hi, I quite frankly know nothing about Javascript. Thought it would be best to get that out of the way from the start. Basically I have a JS menu that is causing me headaches. The menu works fine in the root directory. www.centralhawks.fc.com.au/home.html but when I go to a subdirectory the links for the two sub-menus are all stuffed up. www.centralhawks.fc.com.au/players/damienthompson.html The 2009 results are coming up as www.centralhawksfc.com.au/players/2009seniors.html rather than www.centralhawksfc.com.au/2009seniors.html I have the menuscript.js file saved in both the root directory and players directory. I have tried having the menu in just the root directory, but it doesn't work in the players subdirectory if I do that. The code (which was created by a website, not me), is listed below. I am assuming it is just a simple fix, but as I said I have no idea about any of this. Sorry if I have made the explanation more confusing than it needs to be. Any help would be immensely appreciated. Todd /*** SET BUTTON'S FOLDER HERE ***/ var buttonFolder = "buttons/"; /*** SET BUTTONS' FILENAMES HERE ***/ upSources = new Array("button1up.png","button2up.png","button3up.png","button4up.png","button5up.png","button6up.png","button7up.png","button8up.png","button9up.png","button10up.png","button11up.png","button12up.png","button13up.png","button14up.png"); overSources = new Array("button1over.png","button2over.png","button3over.png","button4over.png","button5over.png","button6over.png","button7over.png","button8over.png","button9over.png","button10over.png","button11over.png","button12over.png","button13over.png","button14over.png"); // SUB MENUS DECLARATION, YOU DONT NEED TO EDIT THIS subInfo = new Array(); subInfo[1] = new Array(); subInfo[2] = new Array(); subInfo[3] = new Array(); subInfo[4] = new Array(); subInfo[5] = new Array(); subInfo[6] = new Array(); subInfo[7] = new Array(); subInfo[8] = new Array(); subInfo[9] = new Array(); subInfo[10] = new Array(); subInfo[11] = new Array(); subInfo[12] = new Array(); subInfo[13] = new Array(); subInfo[14] = new Array(); //*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***// subInfo[2][1] = new Array("Seniors","2009seniors.html",""); subInfo[2][2] = new Array("Reserves","2009reserves.html",""); subInfo[2][3] = new Array("Underage","2009underage.html",""); subInfo[4][1] = new Array("Seniors","pastseniors.html",""); subInfo[4][2] = new Array("Reserves","pastreserves.html",""); subInfo[4][3] = new Array("Underage","pastunderage.html",""); //*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***// var xSubOffset = 131; var ySubOffset = 3; //*** NO MORE SETTINGS BEYOND THIS POINT ***// var overSub = false; var delay = 1000; totalButtons = upSources.length; // GENERATE SUB MENUS for ( x=0; x // SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU if ( subInfo[x+1].length < 1 ) { document.write(' '); // SET DIV FOR BUTTONS WITH SUBMENU } else { document.write(' document.write('onMouseOver="overSub=true;'); document.write('setOverImg(\'' + (x+1) + '\',\'\');"'); document.write('onMouseOut="overSub=false;'); document.write('setTimeout(\'hideSubMenu(\\\'submenu' + (x+1) + '\\\')\',delay);'); document.write('setOutImg(\'' + (x+1) + '\',\'\');">'); document.write(' '); for ( k=0; k document.write(''); document.write(' document.write('target="' + subInfo[x+1][k+1][2] + '">'); document.write( subInfo[x+1][k+1][0] + ''); document.write(''); } document.write(''); } document.write(' ');} //*** MAIN BUTTONS FUNCTIONS ***// // PRELOAD MAIN MENU BUTTON IMAGES function preload() { for ( x=0; x buttonUp = new Image(); buttonUp.src = buttonFolder + upSources[x]; buttonOver = new Image(); buttonOver.src = buttonFolder + overSources[x]; } } // SET MOUSEOVER BUTTON function setOverImg(But, ID) { document.getElementById('button' + But + ID).src = buttonFolder + overSources[but-1]; } // SET MOUSEOUT BUTTON function setOutImg(But, ID) { document.getElementById('button' + But + ID).src = buttonFolder + upSources[but-1]; } //*** SUB MENU FUNCTIONS ***// // GET ELEMENT ID MULTI BROWSER function getElement(id) { return document.getElementById ? document.getElementById(id) : document.all ? document.all(id) : null; } // GET X COORDINATE function getRealLeft(id) { var el = getElement(id); if (el) { xPos = el.offsetLeft; tempEl = el.offsetParent; while (tempEl != null) { xPos += tempEl.offsetLeft; tempEl = tempEl.offsetParent; } return xPos; } } // GET Y COORDINATE function getRealTop(id) { var el = getElement(id); if (el) { yPos = el.offsetTop; tempEl = el.offsetParent; while (tempEl != null) { yPos += tempEl.offsetTop; tempEl = tempEl.offsetParent; } return yPos; } } // MOVE OBJECT TO COORDINATE function moveObjectTo(objectID,x,y) { var el = getElement(objectID); el.style.left = x; el.style.top = y; } // MOVE SUBMENU TO CORRESPONDING BUTTON function showSubMenu(subID, buttonID) { hideAllSubMenus(); butX = getRealLeft(buttonID); butY = getRealTop(buttonID); moveObjectTo(subID,butX+xSubOffset, butY+ySubOffset); } // HIDE ALL SUB MENUS function hideAllSubMenus() { for ( x=0; x moveObjectTo("submenu" + (x+1) + "",-500, -500 ); } } // HIDE ONE SUB MENU function hideSubMenu(subID) { if ( overSub == false ) { moveObjectTo(subID,-500, -500); } } //preload(); Quote Link to comment Share on other sites More sharing options...
jlhaslip Posted April 2, 2009 Report Share Posted April 2, 2009 That Domain name is not yet propagated, so I cannot inspect the site. Cut and paste will get you every time. Quote Link to comment Share on other sites More sharing options...
Guest toddhill Posted April 2, 2009 Report Share Posted April 2, 2009 (edited) Edit. Sorry I stuffed it up. It has me going so batty that I can't even type my own site address. It is www.centralhawksfc.com.au/home.html and www.centralhawksfc.com.au/players/damienthompson.html Edited April 2, 2009 by toddhill Quote Link to comment Share on other sites More sharing options...
Andrea Posted April 2, 2009 Report Share Posted April 2, 2009 The path to your js file is off - it sits in your root directory, that's why type="text/javascript"> works on your index page, but not on your subpages. Change it to: Quote Link to comment Share on other sites More sharing options...
Andrea Posted April 2, 2009 Report Share Posted April 2, 2009 I was just looking at your code some more - and I think you have issues other than a JavaScript menu - what's all this? style="border: 0px solid rgb(0, 0, 0); padding: 0px; position: absolute; top: 0px; left: 0px; right: 0px; width: 100%; height: 168px; background-color: rgb(255, 255, 255);" id="top"> style="font-weight: bold;"> style="color: rgb(153, 102, 51);"> style="font-weight: bold;"> style="font-weight: bold;"> style="font-weight: bold;"> style="font-weight: bold;"> style="font-weight: bold;">CENTRAL HAWKS style="top: 0px; left: 0px; width: 180px; height: 137px;" align="middle"> FOOTBALL CLUB style="font-weight: bold;"> All THAT for four words and one image? Quote Link to comment Share on other sites More sharing options...
Guest toddhill Posted April 2, 2009 Report Share Posted April 2, 2009 Hi, Thank you so much for your reply. I will go and give it a go right now. I did the design in Dreamweaver, and just work through design view, not code. I have no idea where all that comes from. Quote Link to comment Share on other sites More sharing options...
Guest toddhill Posted April 2, 2009 Report Share Posted April 2, 2009 (edited) It didn't work unfortunately. And now when I go to the page the buttons aren't there until I scroll over them and they show up. I hate not being able to fix this stuff myself and hassling others to help Edited April 2, 2009 by toddhill Quote Link to comment Share on other sites More sharing options...
Andrea Posted April 2, 2009 Report Share Posted April 2, 2009 Maybe you have the same path issue with the images? Quote Link to comment Share on other sites More sharing options...
Guest toddhill Posted April 2, 2009 Report Share Posted April 2, 2009 I am pretty much just going to give up on it. I have been trying to do this site for about 4 months and the football season will be over before it is anywhere near ready. Thanks for your help Quote Link to comment Share on other sites More sharing options...
Guest toddhill Posted April 2, 2009 Report Share Posted April 2, 2009 Ok I don't give up that easily. I got the buttons working again fine. I am just back to those pesky links having /players/ in them. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.