views:

7929

answers:

6

How can I do that, so whenever a user clicks a link we play a sound? Using javascript and jquery here.

A: 

First things first, i'd not like that as a user.

The best way to do is probably using a small flash applet that plays your sound in the background.

Also answered here: http://stackoverflow.com/questions/187098/cross-platform-cross-browser-way-to-play-sound-from-javascript

Javache
What's so bad about it if the user knows a sound would be played?
lc
+3  A: 

Found something like that:

//javascript:
function playSound( url ){   
  document.getElementById("sound").innerHTML="<embed src='"+url+"' hidden=true autostart=true loop=false>";
}
Peter
+4  A: 

There seems to be a similar question, with anwsers for prototype, mootools, jquery and others: http://stackoverflow.com/questions/187098/cross-platform-cross-browser-way-to-play-sound-from-javascript

Tuxified
+2  A: 

JavaScript Sound Manager:

http://www.schillmania.com/projects/soundmanager2/

epascarello
A: 
$('a').click(function(){
    $('embed').remove();
    $('body').append('<embed src="/path/to/your/sound.wav" autostart="true" hidden="true" loop="false">');
});
Andrew Philpott
A: 

check this link

http://www.yourblogfamily.com/BlogDetails.aspx?bId=33

jay