Log in

View Full Version : Change Image On Mouseover, retain onclick And play a sound!



TicTacWoe
12-30-2009, 04:41 AM
Ok this might be too much to ask but here goes..

A-I want an image that when a user mouses over it swaps with another image

B-I want this new image on mouseover to be retained if it is then clicked on (ie when clicked the new image which previously only appeared onmouseover has now swapped with the original)

C-As well as the image being retained onclick I'd also like a short sound wav. to play when clicked (which would also stop playing upon being re-clicked).

I know that the combination of A and B are possible (but not entirely sure how to do it) but I have no idea how to also add the play sound on click as well.

The other issue is that most of the play sound file tecniques don't work cross browser but I'd be happy enough if I could get this working in at least IE and FF.

If anyone can tell me how to do this I'd be very happy!

smrnsmile
12-30-2009, 06:39 AM
you can make the buttons in flash and add sounds onmouseover, but i dont think it is possible in html / javascript to add sounds on butns.

kathryn
01-06-2010, 05:48 PM
I had sort of the same problem. This probably isn't the correct way to do it, but it worked. I used onMousedown="playsound(sound1)" onClick="playsound(sound2)". The "sound2" file was empty, so the 2nd produced no sound.