我試圖設置一個客戶端的網站來播放頁面加載(在他的需求,而不是我的首選功能)的音頻文件。我已經使用了一些簡單的JavaScript,但音頻在頁面加載時不播放。任何想法爲什麼發生這種情況?音頻不播放 - JavaScript
<head>
<!--other metadata up here-->
<script>
function EvalSound(soundobj) {
var thissound = document.getElementById(soundobj);
thissound.Play();
}
</script>
<embed src="scripts/audio.wav" autostart=true width=1 height=1 id="audio"
enablejavascript="true">
</head>
<body>
<div id="container" onload="EvalSound('audio')">
<!--rest of page>
</body>
什麼是放在HTML內的最好的地方? – mikedugan
把'audio'標籤放在'body'的某個地方,然後'Javascript'放在底部,靠近'body'標籤。 –