Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Multiple event handler problem?
01-07-2012, 08:50 PM #1
- Join Date
- Jan 2012
- Thanked 0 Times in 0 Posts
Multiple event handler problem?
I did the first one fine - it worked perfectly, but as soon as I added the rest they all stopped working properly. The best I have got, is that the last link will do what it's supposed to regardless of which link I hover over! Which is strange. So the browser seems to be actioning the last thing on the list if that makes sense. It seems to me that I need to add an "if" type attribute, so "if" I hover over the home button, the home images change, as opposed to the last one on the list.
This is the code I have so far for a single link - the rest are copies of this with adjustments made to the imgname and image sources obviously.....
<div style="width:80px; height:20px;margin-top:20px;margin-left:85px;"><a href="about.html"
onMouseOut= "return changeImageBack()"
name="aboutbutton" src="img/aboutn.png" width="80" height="20" border="0"
upImage = new Image();
upImage.src = "img/abouth.png";
downImage = new Image();
downImage.src = "img/aboutc.png"
normalImage = new Image();
normalImage.src = "img/aboutn.png";
document.images["aboutbutton"].src = normalImage.src;
document.images["aboutbutton"].src = downImage.src;
Any suggestions on where I am going wrong would be wonderful.
Thanks so much in advance!
All the best
01-07-2012, 11:16 PM #2
- Join Date
- Dec 2010
- Thanked 569 Times in 562 Posts
It should work fine if you have different names for the images AND different names for the functions/event handlers ...