/    Sign up×
Community /Pin to ProfileBookmark

HELP: mouseover, only 3 links loading

Hi,

I have tried out 2 differant codes for a series of 6 mouseover links.
Both of them result in only loading the first 3 image links.

code 1:

<html>
<head>
<SCRIPT LANGUAGE=”JavaScript”><!–
if (document.images) {
name1on = new Image();name1on.src = ‘files/ciotat/knopLArriveeduntrainanim.gif’; name1off = new Image();name1off.src = ‘files/ciotat/knopLArriveeduntrain.gif’;
name2on = new Image();name2on.src = ‘files/nosferatu/knopnosferatuanim.gif’; name2off = new Image();name2off.src = ‘files/nosferatu/knopnosferatu.gif’;
name3on = new Image();name3on.src = ‘files/phantom/knopphantomanim.gif’; name3off = new Image();name3off.src = ‘files/phantom/knopphantom.gif’;
name4on = new Image();name4on.src = ‘files/metropolis/knopmetrpolisanim.gif’; name4off = new Image();name4off.src = ‘files/metropolis/knopmetrpolis.gif’;
name5on = new Image();name5on.src = ‘files/unchien/knopunchienanim.gif’; name5off = new Image();name5off.src = ‘files/unchien/knopunchien.gif’;
name6on = new Image();name6on.src = ‘files/moderntimes/moderntimesanim.gif’; name6off = new Image();name6off.src = ‘files/moderntimes/moderntimes.gif’;
}

function swapOn(name) {
if (document.images)
document.images[name].src = eval(name + ‘on.src’);
}

function swapOff(name) {
if (document.images)
document.images[name].src = eval(name + ‘off.src’);
}
//–></SCRIPT>
<title>Untitled Document</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
</head>

<body bgcolor=”#000000″>

<center>
<A HREF=”page1.htm” onMouseOver=”swapOn(‘name1’)” onMouseOut=”swapOff(‘name1’)”><IMG NAME=”name1″ SRC=”files/ciotat/knopLArriveeduntrain.gif” BORDER=”0″></A></td>
<A HREF=”page2.htm” onMouseOver=”swapOn(‘name2’)” onMouseOut=”swapOff(‘name2’)”><IMG NAME=”name2″ SRC=”files/nosferatu/knopnosferatu.gif” BORDER=”0″></A></td>
<A HREF=”page3.htm” onMouseOver=”swapOn(‘name3’)” onMouseOut=”swapOff(‘name3’)”><IMG NAME=”name3″ SRC=”files/phantom/knopphantom.gif” BORDER=”0″></A></td>
<A HREF=”page4.htm” onMouseOver=”swapOn(‘name4’)” onMouseOut=”swapOff(‘name4’)”><IMG NAME=”name4″ SRC=”files/metropolis/knopmetrpolis.gif” BORDER=”0″></A></td>
<A HREF=”page5.htm” onMouseOver=”swapOn(‘name5’)” onMouseOut=”swapOff(‘name5’)”><IMG NAME=”name5″ SRC=”files/unchien/knopunchien.gif” BORDER=”0″></A></td>
<A HREF=”page6.htm” onMouseOver=”swapOn(‘name6’)” onMouseOut=”swapOff(‘name6’)”><IMG NAME=”name6″ SRC=”files/moderntimes/moderntimes.gif”BORDER=”0″></A></td>
</center>
</body>
</html>

code 2:

<html>
<head><SCRIPT LANGUAGE=”JavaScript”><!–
var totalImages = 12// Total images used

if(document.images){
mFX = new Array(totalImages);
for(i = 0; i < mFX.length; i++){
mFX[i] = new Image();
}
mFX[0].src = “files/ciotat/knopLArriveeduntrainanim.gif”;
mFX[1].src = “files/ciotat/knopLArriveeduntrain.gif”;
mFX[2].src = “files/nosferatu/knopnosferatuanim.gif”;
mFX[3].src = “files/nosferatu/knopnosferatu.gif”;
mFX[4].src = “files/phantom/knopphantomanim.gif”;
mFX[5].src = “files/phantom/knopphantom.gif”;
mFX[6].src = “files/metropolis/knopmetrpolisanim.gif”;
mFX[7].src = “files/metropolis/knopmetrpolis.gif”;
mFX[8].src = “files/unchien/knopunchienanim.gif”;
mFX[9].src = “files/unchien/knopunchien.gif”;
mFX[10].src = “files/moderntimes/moderntimesanim.gif”;
mFX[11].src = “files/moderntimes/moderntimes.gif”;
}
function imgFX(img, num){
if(document.images){
document.images[img].src = mFX[num].src;
}
}
</SCRIPT>
<title>Untitled Document</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
</head>
<body bgcolor=”#000000″>

<center>

<a href=”http://www.skynet.be” onmouseover=”imgFX(‘first’,0);” onmouseout=”imgFX(‘first’,1);”><img name=”first” src=”files/ciotat/knopLArriveeduntrain.gif” border=”0″/></a></td>
<a href=”http://www.skynet.be” onmouseover=”imgFX(‘second’,2);” onmouseout=”imgFX(‘second’,3);”><img name=”second” src=”files/nosferatu/knopnosferatu.gif” border=”0″/></a></td>
<a href=”http://www.skynet.be” onmouseover=”imgFX(‘third’,4);” onmouseout=”imgFX(‘third’,5);”><img name=”third” src=”files/phantom/knopphantom.gif” border=”0″/></a></td>
<a href=”http://www.skynet.be” onmouseover=”imgFX(‘fourth’,6);” onmouseout=”imgFX(‘fourth’,7);”><img name=”fourth” src=”files/metropolis/knopmetrpolis.gif” border=”0″/></a></td>
<a href=”http://www.skynet.be” onmouseover=”imgFX(‘fifth’,8);” onmouseout=”imgFX(‘fifth’,9);”><img name=”fifth” src=”files/unchien/knopunchien.gif” border=”0″/></a></td>
<a href=”http://www.skynet.be” onmouseover=”imgFX(‘sixth’,10);” onmouseout=”imgFX(‘sixth’,11);”><img name=”sixth” src=”files/moderntimes/moderntimes.gif” border=”0″/></a></td>
</center>
</body>
</html>

What am i doing wrong ?
I tried it on both Firefox and IE.

Desperate !

Björn

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@CharlesSep 10.2006 — I expect that you've got the file names wrong somehow. Remember that the internet is case sensiteve.

Do consider, however, giving up on JavaScript rollovers in favor on CSS. They're easier, quicker, better supported and you don't have to worry about pre-loading. http://www.alistapart.com/articles/sprites/
×

Success!

Help @bxlbjorn spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...