Help - Search - Members - Calendar
Full Version: Linking to home page
HTMLHelp Forums > Web Authoring > Markup (HTML, XHTML, XML)
co_gooner
Hi there,

I have a Work in progress website called www.stripephoto.com

The index page loads up nicely and the sub level links below 'seniors' button works perfectly, but I can't seem to get the 'home' page button to load up the index.html page, it asks for 'Link 1' which I see in the .js file (coding below) and the .html files but I don't know how to make it work. PLease bear in mind that all the fancy code has been gathered from the many very helpful free sites on the net and my own level of skill is pretty limited.

Any help is much, much appreciated

thanks

david


the menuscript.js code is below:

/*** 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");

overSources = new Array("button1over.png","button2over.png","button3over.png","button4over.png","button5over.png","button6over.png","button7over.png","button8over.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();


//*** SET SUB MENUS TEXT LINKS AND TARGETS HERE ***//

subInfo[2][1] = new Array("About","seniors_about.html");
subInfo[2][2] = new Array("Portfolio","seniors_folio.html");
subInfo[2][3] = new Array("Rates","seniors_rates.html");
subInfo[2][4] = new Array("Customer Area","seniors_cust.html");

subInfo[3][1] = new Array("About","Sub-Link 1","portraits_about.html");
subInfo[3][2] = new Array("Portfolio","Sub-Link 2","portraits_folio.html");
subInfo[3][3] = new Array("Rates","Sub-Link 3","portraits_rates.html");
subInfo[3][4] = new Array("Customer Area","Sub-Link 4","portraits_cust.html");

subInfo[4][1] = new Array("About","Sub-Link 1","weddings_about.html");
subInfo[4][2] = new Array("Portfolio","Sub-Link 2","weddings_folio.html");
subInfo[4][3] = new Array("Rates","Sub-Link 3","weddings_rates.html");
subInfo[4][4] = new Array("Customer Area","Sub-Link 4","weddings_cust.html");






//*** SET SUB MENU POSITION ( RELATIVE TO BUTTON ) ***//
var xSubOffset = 120;
var ySubOffset = 7;



//*** NO MORE SETTINGS BEYOND THIS POINT ***//
var overSub = false;
var delay = 1000;
totalButtons = upSources.length;

// GENERATE SUB MENUS
for ( x=0; x<totalButtons; x++) {
// SET EMPTY DIV FOR BUTTONS WITHOUT SUBMENU
if ( subInfo[x+1].length < 1 ) {
document.write('<div id="submenu' + (x+1) + '">');
// SET DIV FOR BUTTONS WITH SUBMENU
} else {
document.write('<div id="submenu' + (x+1) + '" class="dropmenu" ');
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('<ul>');
for ( k=0; k<subInfo[x+1].length-1; k++ ) {
document.write('<li>');
document.write('<a href="' + subInfo[x+1][k+1][1] + '" ');
document.write('target="' + subInfo[x+1][k+1][2] + '">');
document.write( subInfo[x+1][k+1][0] + '</a>');
document.write('</li>');
}
document.write('</ul>');
}
document.write('</div>');
}





//*** MAIN BUTTONS FUNCTIONS ***//
// PRELOAD MAIN MENU BUTTON IMAGES
function preload() {
for ( x=0; x<totalButtons; 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<totalButtons; x++) {
moveObjectTo("submenu" + (x+1) + "",-500, -500 );
}
}

// HIDE ONE SUB MENU
function hideSubMenu(subID) {
if ( overSub == false ) {
moveObjectTo(subID,-500, -500);
}
}



//preload();
pandy
No, it's in the HTML. You have written the URL as the value of target instead of href. It's the same problem with the othger links too.

HTML
<a href="Link 1" onMouseOver="setOverImg('1','');overSub=true;
showSubMenu('submenu1','button1');" onMouseOut="setOutImg('1','');
overSub=false;setTimeout('hideSubMenu(\'submenu1\')',delay);"
target="index.html">


Don't know what that 'Link 1' is supposed to be. If you don't want the links to open in a new window, remove target altogether.
co_gooner
Thanks for replying; I've tried <a href="index.html" instead of Link 1, but that doesn't work either, when I click on the home page button I get the message:

Firefox can't find the file at /I:/Stripe_Photography/28_Jan_menu/New_buttons/Link 1.

The Link 1 came from the original code where I found the code to create the buttons

QUOTE(pandy @ Jan 30 2009, 04:40 PM) *

No, it's in the HTML. You have written the URL as the value of target instead of href. It's the same problem with the othger links too.

HTML
<a href="Link 1" onMouseOver="setOverImg('1','');overSub=true;
showSubMenu('submenu1','button1');" onMouseOut="setOutImg('1','');
overSub=false;setTimeout('hideSubMenu(\'submenu1\')',delay);"
target="index.html">


Don't know what that 'Link 1' is supposed to be. If you don't want the links to open in a new window, remove target altogether.
pandy
QUOTE(co_gooner @ Feb 1 2009, 09:18 PM) *

Firefox can't find the file at /I:/Stripe_Photography/28_Jan_menu/New_buttons/Link 1.


Can you upadate the online page so we can see what happens?

CODE
The Link 1 came from the original code where I found the code to create the buttons


Then they are placeholders that you are supposed to change to real URLs.
co_gooner
QUOTE(pandy @ Feb 1 2009, 01:39 PM) *

QUOTE(co_gooner @ Feb 1 2009, 09:18 PM) *

Firefox can't find the file at /I:/Stripe_Photography/28_Jan_menu/New_buttons/Link 1.


Can you upadate the online page so we can see what happens?

CODE
The Link 1 came from the original code where I found the code to create the buttons


Then they are placeholders that you are supposed to change to real URLs.


I've got to work now, thanks

I was just wondering how to control the sub links opening in a new page? I'm presuming that this is controlled in the javascript, but I'm not sure where

thanks again

david
pandy
The other links still look the same, no URLs in the href and funky targets. You must fix all of them. Those links are what people will get without JS.

As for the script, the problem is similar. You seem to have got it right for the Seniors section. Those links work as you want, right?

CODE
subInfo[2][1] = new Array("About","seniors_about.html");
subInfo[2][2] = new Array("Portfolio","seniors_folio.html");
subInfo[2][3] = new Array("Rates","seniors_rates.html");
subInfo[2][4] = new Array("Customer Area","seniors_cust.html");



But below that you have used a target. You have written the URL where you should have the name of the target (had you wanted one) and you have that sub-link stuff where the URL should be.

CODE

subInfo[3][2] = new Array("Portfolio","Sub-Link 2","portraits_folio.html");
subInfo[3][3] = new Array("Rates","Sub-Link 3","portraits_rates.html");
subInfo[3][4] = new Array("Customer Area","Sub-Link 4","portraits_cust.html");


Remove the target parameter and write the URL as the second parameter. Like so.

CODE
subInfo[3][1] = new Array("About","portraits_about.html");


I think that will work.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.