This article describes the JS to the Web page plus background music and choose the sound effects method. Share to everyone for your reference. The implementation methods are as follows:
Copy Code code as follows:
<HTML>
<HEAD>
<TITLE> Add background music to the Web page, select Sound function </TITLE>
<STYLE>
<!--style sheet-->
A{font-size:30pt;color:blue;font-family:vineta BT}
A:link{text-decoration:none;}
A:hover{text-decoration:none;color:red}
A:visited{text-decoration:none;}
.20pt{font-size:20pt;color: #ff66cc}
</STYLE>
<script language=javascript>
var mid=new Array ()
mid[1]= "Sound/201101/s01.wav"
mid[2]= "Sound/201101/s02.wav"
function Clicksound (i)
{
Document.all.sound.src=mid[i]
}
</script>
</HEAD>
<BODY>
<bgsound id=sound src= "" loop=1>
<bgsound src= "Sound/201101/abuse.mid" >
<center>
<a href= "#" onclick= "Clicksound (1)" >no! No! No!</a><br>
<a href= "#" onclick= "Clicksound (2)" >you win! cheer!</a><br>
<HR width=700>
<font class=20pt> mouse clicks on the above content, there will be a dynamic background sound </font>
</center>
</BODY>
</HTML>
I hope this article will help you with your JavaScript programming.