我想播放声音 onclick 事件。我有代码可以在 Firefox 和其他浏览器中播放声音,但不能在 safari 中播放。
下面是代码。 Safari 给我这样的错误 "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 保留在脚本标签之间。
关于javascript - 在 safari 中使用 javascript 播放声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4224140/