js's method of adding background music and selecting sound effects to web pages

  • 2020-05-10 17:39:38
  • OfStack

This article illustrates how js adds background music to web pages and selects sound effects. Share with you for your reference. The specific implementation method is as follows:

<HTML>
<HEAD>
<TITLE> Add background music to the page and select sound effects </TITLE>
<STYLE>
<!-- stylesheets -->
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! cheers !</a><br>
<hr width=700>
<font class=20pt> When you click on the above , There will be dynamic background sound </font>
</center>
</BODY>
</HTML>

I hope this article has been helpful to your javascript programming.


Related articles: