How js adds background music to webpages and selects sound effects
This article mainly introduces how to add background music and select sound effects to the webpage by js. It involves the javascript audio operation technique and has some reference value. If you need it, you can refer to it.
This article describes how to add background music and select sound effects to a webpage by js. Share it with you for your reference. The specific implementation method is as follows:
The Code is as follows:
<HTML>
<HEAD>
<TITLE> Add background music to the webpage and select the sound effect 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! Cheers! </A> <br>
<Hr width = 700>
<Font class = 20pt> when you click the content above, a dynamic background sound is displayed. </font>
</Center>
</BODY>
</HTML>
I hope this article will help you design javascript programs.