Playing sound notifications using Javascript?

Viewed 193379

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

10 Answers

Found something like that:

//javascript:
function playSound( url ){   
  document.getElementById("sound").innerHTML="<embed src='"+url+"' hidden=true autostart=true loop=false>";
} 
$('a').click(function(){
    $('embed').remove();
    $('body').append('<embed src="/path/to/your/sound.wav" autostart="true" hidden="true" loop="false">');
});
Related