【发布时间】:2011-05-04 05:35:25
【问题描述】:
我有一个 HTML5 应用程序,它本质上是一个音板。您单击一个图像,它会播放一个 mp3 文件。它在 Chrome 上运行良好,但在我的 iPad Safari 上运行良好。函数如下所示:
<script type="text/javascript">
function playSound(theSound) {
soundDir = "./sounds/";
filename = soundDir + theSound;
sound = new Audio(soundDir + theSound);
sound.setAttribute("autoplay", "autoplay");
document.getElementsByTagName("body")[0].appendChild(sound);
return true;
}
</script>
它是这样称呼的:
onclick=playSound("knife.mp3")
我做错了什么?
【问题讨论】: