<!--
var sound1="midi/1.mid"
var sound2="midi/2.mid"
var sound3=">

Javascript实现音乐随机播的代码

80酷酷网    80kuku.com

  javascript|随机

  将以下代码放在<head>与</head>之间即可。

<SCRIPT language="JavaScript">
<!--
var sound1="midi/1.mid"
var sound2="midi/2.mid"
var sound3="midi/3.mid"
var sound4="midi/4.mid"
var sound5="midi/5.mid"
var sound6="midi/6.mid"
var sound7="midi/7.mid"
var sound8="midi/8.mid"
var sound9="midi/9.mid"
var sound10="midi/10.mid"
var x=Math.round(Math.random()*9)
if (x==0) x=sound1
else if (x==1) x=sound2
else if (x==2) x=sound3
else if (x==3) x=sound4
else if (x==4) x=sound5
else if (x==5) x=sound6
else if (x==6) x=sound7
else if (x==7) x=sound8
else if (x==8) x=sound9
else x=sound10
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>



分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: