This article is an example of JS control of the Web page background music playback and stop method. Share to everyone for your reference. The implementation methods are as follows:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>js Bgsound method for controlling background music (start and stop) </title>
<body>
<script type= "Text/javascript" >
var bg_sound=document.createelement_x ("Bgsound");//Create background music
Bg_sound.id= "I_BG"//Set ID attribute
Document.body.appendChild (bg_sound); add background music to//body
Bg_sound.src= "Tmp3.mp3";
I_bg.src= "Tmp3.mp3";/set a background music file
It should also be written with write, you can try the effect.
function Bg_stop () {
I_bg.src= "";
}
function Bg_start () {
I_bg.src= "Tmp3.mp3";
}
</script>
<span ><a onclick= "javascript:bg_stop ();" href= "javascript:void (0);" > Background music stop </a></span> <span ><a onclick= "Javascript:bg_start ();" href= "javascript:void (0);" > Background music start </a></span>
</body>
I hope this article will help you with your JavaScript programming.