Play sound using javascript in safari
I want to play sound onclick event. I have code in which i can play sound in Firefox and other browser but not in safari.
Below is the code. Safari gives me the error like "thissound.Play" [undefined ] is not a function
.
function EvalSound(soundobj) {
var thissound= eval("document."+soundobj);
thissound.Play();
}
<embed src="namaste_london01(www.开发者_如何学JAVAsongs.pk).mp3" autostart=false width=0 height=0 name="sound1"
enablejavascript="true">
<a href="#" onClick="EvalSound('sound1')"> Play </a>
Thanks in advance.
jQuery has some great audio plugins. It also means you can get rid of nasty onclick attributes, and so keep all your javascript between the script tags.
精彩评论