Add active background music to your Web page, which can be changed to interactive menu!
Source: Internet
Author: User
Design idea and realization method
1. First create <EMBED> embed tags in html, embed the track files available for selection,
*.wav, *.au, *.mid, and so on, the code is as follows:
<embed name= "MUSIC1" src= "Track 1 sound Files" loop=-1
Autostart=false hidden=true mastersound>
<embed name= "MUSIC1" src= "Track 2 sound Files" Loop=-1
Autostart=false hidden=true mastersound>
Loop=-1 in code let tracks play again
Autostart=false prevent tracks from being embedded and play automatically
Hidden=true Hide it, not visible
2. Use <SELECT>...</SELECT> and <OPTION>...</OPTION> to establish alternative
The Drop-down list box for the track,
<form name= "My_music" width=300>
<select name= "opt" size=1 onchange= "Javascript:my_sound ()" >
<option value= "0" selected>------no------</option>
<option value= "1" > Track 1</option>
<option value= "2" > Track 2</option>
</form>
3. Go to the HTML document's <HEAD> tag to write a function to implement track replacement, as follows:
function My_sound ()
{
if (MSIE4)//is IE 4.0 above version
{
if (document.my_music.opt.value== "1")//Select track 1
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.