我试图设置一个客户端的网站来播放页面加载(在他的需求,而不是我的首选功能)的音频文件。我已经使用了一些简单的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'标签。 –