45、随机播放背景音乐的脚本

45、随机播放背景音乐的脚本

脚本说明:

把如下代码加入<body>区域中

<SCRIPT language="JavaScript">

<!--

var sound1="sto/song1.mid"

var sound2="sto/song2.mid"

var sound3="sto/song1.mid"

var sound4="sto/song2.mid"

var sound5="sto/song1.mid"

var sound6="sto/song2.mid"

var sound7="sto/song1.mid"

var sound8="sto/song2.mid"

var sound9="sto/song1.mid"

var sound10="sto/song2.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>

 

 

Write a comment

Comments: 0