随机播放音乐

这个脚本能教网页打开时随机播放不同midi音乐。拷贝以下脚本后贴在有关网页的<head></head>之间。别忘了上载有关的Midi文件,5并把脚本中的样板文件名 (绿色部分) 更改过来。


<script>
<!--
var sound1="1.mid"
var sound2="2.mid"
var sound3="3.mid"
var sound4="4.mid"
var sound5="5.mid"
var x=Math.round(Math.random()*4)
if (x==0) x=sound1
else if (x==1) x=sound2
else if (x==2) x=sound3
else if (x==3) x=sound4
else x=sound5
if (navigator.appName=="Microsoft Internet Explorer")
document.write('<bgsound src='+'"'+x+'"'+' loop="infinite">')
else
document.write('<embed src='+'"'+x+'"'+'hidden="true" border="0"
width="20" height="20" autostart="true" loop="true">')
//-->
</script>


就是如此简单!
请享用