lena
lena

Reputation: 119

Looking for a mouseover sound script

I'm looking for a a mouseover sound script (for button). I plan to use wav sound but it can be another sound format.

Those I have found on the net are not compatible with new browser version. I especially it need to work in Firefox.

I have found one on Jquery site but it requires Flash.

I prefer using only javascript if possible.

Upvotes: 3

Views: 1267

Answers (3)

lena
lena

Reputation: 119

I was not able to find a way to make it work under Firefox, so I decide to use Flash at the end.

Upvotes: 0

sthg
sthg

Reputation: 1135

You can try something like this:

<script type="text/javascript">
function EvalSound(soundobj) {
var thissound=document.getElementById(soundobj);
thissound.Play();
}
</script>
<embed src="mysound.wav" autostart=false width=0 height=0 id="mysound" enablejavascript="true">

Then, to play on mouseover of a link, add the code:

<a href="#" onMouseOver="EvalSound('mysound')">Move mouse here</A>

Upvotes: 0

Jacob
Jacob

Reputation: 78850

Sorry, but JavaScript cannot play sound. You'll find it easiest to work with Flash since it's so commonly installed in browsers. JavaScript can interact with SWFs through the ExternalInterface ActionScript API.

Upvotes: 1

Related Questions