/    Sign up×
Community /Pin to ProfileBookmark

mouseOut doesn’t works under Firefox?!

Could anyone please help me to find out why my javascript doesn’t work under Firefox? I have tested it in IE. It works with no problem. Thanks in advance!

The code is here:

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd“>
<html>

<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″>
<title></title>
<meta name=”description” content=””>
<meta name=”keywords” content=””>
<meta name=”author” content=”Unregistered User”>
<meta name=”generator” content=”AceHTML 6 Pro”>
</head>

<HEAD>
<SCRIPT LANGUAGE=”JavaScript”type=”text/javascript”>

//Set the numbers of images for the navigation
var numbersOfImages = 6;

/*isDown is the variable for the state of images.
Zero means no image has been clicked.
Otherweise menas a image with the value of isDown as index
has been clicked. */
var isDown = 0;

//By loading of the page all images will be set with “taste_oben.gif”.
function onLoad(){
for (i = 1; i <= numbersOfimages; i++ ){
document[‘taste0’ + i].src = “taste_oben.gif”;
}
}

/*On mouse over swap the original image with “taste_unten.gif”,
which has not been clicked.*/
function swapOver(imgIndex){
if (imgIndex != isDown){
document[‘taste0’ + imgIndex].src = “taste_down.gif”;
}
}

/*On mouse out restore the images with “taste_oben.gif”,
which has not been clicked.*/
function swapOut(imgIndex){
if (imgIndex != isDown){
document[‘taste0’ + imgIndex].src = “taste_up.gif”;
}
}

//On click swap the clicked image with “taste_down.gif”.
function swapClick(imgIndex){
//No image has been clicked, if isDown equals zero.
if (isDown != 0){
//When a image has been clicked, restore it with “taste_up.gif”.
document[‘taste0’ + isDown].src = “taste_up.gif”;
}
/*Swap the image that has been newly clicked with “taste_down.gif”
and set the value of isDown with the index of this image. */
document[‘taste0’ + imgIndex].src = “taste_unten.gif”;
isDown = imgIndex;
}

</script>
</HEAD>

<BODY>

<center>
<table>
<tr>
<td valign=”top” align=”left”>
<a href=”#”><img name=”taste01″ src=”taste_oben.gif”
border=”0″ onmouseover=”swapOver(1)” onmouseout=”swapOut(1)”
onclick=”swapClick(1)”></a>
</td>

<td valign=”top” align=”center”>
<a href=”#”><img name=”taste02″ src=”taste_oben.gif”
border=”0″ onmouseover=”swapOver(2)” onmouseout=”swapOut(2)”
onclick=”swapClick(2)”></a>
</td>

<td valign=”top” align=”right”>
<a href=”#”><img name=”taste03″ src=”taste_oben.gif”
border=”0″ onclick=”swapClick(3)” onmouseover=”swapOver(3)”
onmouseout=”swapOut(3)”></a>
</td>

<td valign=”top” align=”right”>
<a href=”#”><img name=”taste04″ src=”taste_oben.gif”
border=”0″ onclick=”swapClick(4)” onmouseover=”swapOver(4)”
onmouseout=”swapOut(4)”></a>
</td>

<td valign=”top” align=”right”>
<a href=”#”><img name=”taste05″ src=”taste_oben.gif”
border=”0″ onclick=”swapClick(5)” onmouseover=”swapOver(5)”
onmouseout=”swapOut(5)”></a>
</td>

<td valign=”top” align=”right”>
<a href=”#”><img name=”taste06″ src=”taste_oben.gif”
border=”0″ onclick=”swapClick(6)” onmouseover=”swapOver(6)”
onmouseout=”swapOut(6)”></a>
</td>

</tr>

</table>
</center>

</BODY>

</html>

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@KravvitzNov 18.2005 — Instead of document[], you should use document.images[], or even better, use document.getElementsByName()[0].
Copy linkTweet thisAlerts:
@qingdaoerauthorNov 18.2005 — Instead of document[], you should use document.images[], or even better, use document.getElementsByName()[0].[/QUOTE]

Hi Kravvitz,

thank you for your answer. I have tried it out. But it still doesn't work in Firefox 1.0.4. Please try my code in IE and then in Firefox. Then you will see what the problems are. Firefox doesn't show the same effect like in IE.

regards,

qingdaoer
Copy linkTweet thisAlerts:
@KorNov 18.2005 — use

document.getElementsByName('taste0' + i)[0].src="taste_oben.gif";

instead of

document['taste0' + i].src = "taste_oben.gif";

and so on...

document[name] is not a valid javascript (ECMAScript) reference, it is an old IE short cut
×

Success!

Help @qingdaoer 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 5.18,
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,
)...