繁体   English   中英

在Safari中使用JavaScript播放声音

[英]Play sound using javascript in safari

我想播放声音onclick事件。 我有可以在Firefox和其他浏览器中播放声音但不能在Safari中播放声音的代码。 下面是代码。 Safari给我类似"thissound.Play" [undefined ] is not a function的错误"thissound.Play" [undefined ] is not a function

function EvalSound(soundobj) {
  var thissound= eval("document."+soundobj);
  thissound.Play();
}

<embed src="namaste_london01(www.songs.pk).mp3" autostart=false width=0 height=0 name="sound1"
enablejavascript="true">

<a href="#" onClick="EvalSound('sound1')"> Play </a>

提前致谢。

jQuery有一些很棒的音频插件。 这也意味着您可以摆脱讨厌的onclick属性,从而将所有JavaScript保留在script标签之间。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM