How to Make Background Music in JS

1. Do an IFRAME, iframe src: music.htm2. Make new htm doc.
Write in it this code in <head>:

<bgsound id=”PlayMusic”>
<script type=”text/javascript”>
<!–
PlayMusic.src=”music.mp3″;
function OnOff() {
if (PlayMusic.src==””)
{
PlayMusic.src=”music.mp3″;
OnOffButton.value=”Stop”;
} else {
PlayMusic.src=””;
OnOffButton.value=”Play”;
}
}
// –>
</script>

replace the file name in “music.mp3”. its not must be mp3, its can be MID or WAV, but the best is MP3 or MID.
now, in the <body> but this:

<input type=”button” name=”OnOffButton” value=”Stop” onClick=”OnOff()”>

and save it as “music.html
the html shod look loke this:

<html>
<head>
<bgsound id=”PlayMusic”>
<script type=”text/javascript”>
<!–
PlayMusic.src=”music.mp3″;
function OnOff() {
if (PlayMusic.src==””)
{
PlayMusic.src=”music.mp3″;
OnOffButton.value=”Stop”;
} else {
PlayMusic.src=””;
OnOffButton.value=”Play”;
}
}
// –>
</script>
</head>
<body bgcolor=”#000000″ scrollamount=”0″>
<input type=”button” name=”OnOffButton” value=”Stop” onClick=”OnOff()”>
</body>
</html>

Now, u have a web site background music without flash!!!

You may also like...