Click to See Complete Forum and Search --> : [RESOLVED] Is there a Magic Mouseover Linked Sound Code?
PearlDoves
08-06-2006, 05:27 AM
Hey all -
I'm looking to have sound play when the mouse cursor goes over an image link (rollover)... if not that, then at the very least when you click the image-link.
When I look into codes on how to do this, there seems to be problems from browser to browser, and perhaps even moreso with the newer browsers....
IS THERE ANY universal code or something simple that can help me achieve my goal? Any help appriecated! Thanks in advance!
Natdrip
08-09-2006, 06:26 PM
http://javascript.internet.com/buttons/dynamic-audio-button.html
try thiis link
PearlDoves
08-11-2006, 01:47 AM
Thanks for your help. BTW, I like your pluky duck quote, lol. I loved that show.
Luis2006
08-11-2006, 11:48 PM
Okay,
1) Write the following within the head tag:
<script type="text/javascript">
function play()
{
track.src = 'sound/metalplate.wavA';
}
</script>
A) You must change the source to wherever your own sound file is located
2) Write the following within your body tag:
<bgsound id="track" src="sound/metalplate.wavA">
<a href="archives2.htmlB" onmouseover="play()">
<img src="images/gallery.gifC" border="0">
A) You must change the source to wherever your own sound file is located
B) You must change to whatever page you want to link
C) In this case the sound onmousever is for a button (image), but you can change that to text. Again you must change the path to wherever you image is located.
I hope this helps.
PearlDoves
08-12-2006, 07:09 AM
Wow, hey thanks!
Could this work with a rollover as well? ;)
Luis2006
08-13-2006, 05:53 AM
Hi Pearl,
Here is the thing. I once saw a nice menu that had buttons that change color and it had what it seemed to be "on mouse over" sound. The problem is I saw it a long time ago before I knew anything about web development and I don't remember the name of the site. Maybe it was Javascript, maybe it was flash.
I have been trying to make a rollover button with onmouseover sound, but no luck so far. I must tell you I am a newbie at this.
So far this is what I have:
First example: The script for a page with sound onmouseover in an image that is NOT a rollover
<html>
<head>
<title> Sound test</title>
<script type="text/javascript">
function play()
{
track.src = 'sound/metalplate.wav';
}
</script>
</head>
<body>
<div style="position: absolute; left: 451; top: 5;">
<bgsound id="track" src="sound/metalplate.wav">
<a href="archives2.html" onmouseover="play()"><img src="images/gallery.gif" border="0"></a>
</div>
</body>
</html>
The problem I have with this script is that you here the sound every time you refresh the page. Regardless of whether your mouse is over the image or not.
Second example: The script for a page with a rollorover image (patience you'll understand in example three)
<html>
<head>
<title>Rollover Button</title>
</head>
<body>
<div style="position: absolute; left: 451; top: 5;">
<img ID=button8 src="images/button8.gif" width=150 height=40 border="0"
onmouseover='document.getElementById("button8").src="images/button8a.gif"'
onmouseout='document.getElementById("button8").src="images/button8.gif"'>
</a>
</body>
</html>
No problem with this page the rollover image(button) seems to work just fine.
Third example: Here is where it stops working. The only thing that comes to mind is put together the two previous examples. It doesn't work, but I don't know why.
<html>
<head>
<title>Sound test II</title>
</head>
<body>
<div style="position: absolute; left: 451; top: 5;">
<bgsound id="track" src="sound/metalplate.wav">
<a href="archives2.html" onmouseover="play()">
<img ID=button8 src="images/button8.gif" width=150 height=40 border="0"
onmouseover='document.getElementById("button8").src="images/button8a.gif"'
onmouseout='document.getElementById("button8").src="images/button8.gif"'>
</a>
</body>
</html>
The problem for me with all this programming is that I learned it by myself from books and the Internet, so sometimes I don't even know if what I am trying to do is possible or if I am just waisting my time.
Please take a look at it. If you happen to find out why it doesn't work or simply another way to do it or if is even possible. I'll appreciate it if you let me know.
Luis
PearlDoves
08-16-2006, 10:43 PM
Thanks for all your help!
I really don't much when it comes to scripting, so I woudln't be able to figure it out, but if you end up posting this in another thread to see if anybody can resolve it, let me know so I can keep tabs on it,
THanks again!,
PearlDoves