PDA

View Full Version : How do I make an unclickable multi-rollover JScript?


noble experiment
12-22-2004, 05:02 PM
I'm working on a layout design for one of my account managers. The main question: Can you have a combination of rollover links and rollover non-links in this javascript rollover I set up for a client? If not, then would CSS mouse-arrow hiding be a better alternative (yet, I find it pretty painful to do).

Here's my script

if(document.images) {

altBlank = new Image;

altmenu01 = new Image;
menu01on = new Image;
menu01off = new Image;

altmenu02 = new Image;
menu02on = new Image;
menu02off = new Image;

homebtn01on = new Image;
homebtn01off = new Image;
homebtn02on = new Image;
homebtn02off = new Image;

photo01 = new Image;
photo02 = new Image;

altBlank.src = "home_showroom.jpg";

altmenu01.src = "home_showroom.jpg";
menu01on.src = "btn_lnc_on.gif";
menu01off.src = "btn_lnc_off.gif";

altmenu02.src = "home_showcase.jpg";
menu02on.src = "btn_bmer_on.gif ";
menu02off.src = "btn_bme_off.gif ";
// ....

homebtn01on.src = "homebn_lnc_on.gif";
homebtn01off.src = "homebn_lnc_off.gif";
homebtn02on.src = "homebn_bme_on.gif";
homebtn02off.src = "homebn_bme_off.gif";
// ....

photo01.src = "home01_healthcare.jpg";
photo02.src = "home01_education.jpg";
....
}

// AltSwitch Function

function altswitch(imagename) {
document.altmenu.src=eval(imagename + ".src");
}

// AltSwitchTwo Function

function altswitchtwo(imagename) {
document.altphototwo.src=eval(imagename + ".src");
}

// AltSwitchThree Function

function altswitchthree(imagename) {
document.altphotothree.src=eval(imagename + ".src");
}

// AltSwitchFour Function

function altswitchfour(imagename) {
document.altphotofour.src=eval(imagename + ".src");
}

// AltSwitchFive Function

function altswitchfive(imagename) {
document.altphotofive.src=eval(imagename + ".src");
}

// AltSwitchSix Function

function altswitchsix(imagename) {
document.altphotosix.src=eval(imagename + ".src");
}

// MouseOver Function

function swapOn(imgLocation) {
if(document.images) {
document.images[imgLocation].src = eval(imgLocation + "on.src");
}
}

// MouseOut Function

function swapOff(imgLocation) {
if(document.images) {
document.images[imgLocation].src = eval(imgLocation + "off.src");
}
}

Zee
01-02-2005, 04:18 AM
There's nothing in the code that makes an image a link... the important part seems to be left out!

It also appears to be pretty poorly written. I'd never use eval and I'd combine those functions into a single function...


function switchImage(imgName, withImg) {
if (document.images) //save users of older browsers
document.images[imgName].src = window[withImg].src;
//all 'global' properties are part of the window object. Avoid using eval!
}
Send the relevant code to get to the problem at hand!

Regards