开发者

Play sound using javascript in safari

开发者 https://www.devze.com 2023-01-25 17:56 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消