我正在尝试在拍卖网站中嵌入声音。我希望每次有人出价时都会播放声音。我尝试了一个带有给定 ID 的简单<embed>
标签,然后sound.play()
通过 javascript。
声音正在播放,但在 IE 中,“如果他/她信任该网站”,则要求新用户安装媒体播放器扩展。
有没有办法让它在没有这个消息的情况下播放。以下代码在页面中:
在 HTML 中:
<embed src="success.wav" autostart="false" width="0" height="0" id="sound1"
enablejavascript="true">
在 Javascript 中:
function PlaySound(soundObj) {
var sound = document.getElementById(soundObj);
sound.Play();
}
以及对函数的调用:
PlaySound("sound1");