我有一个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")
我做错了什么?