Lisa said:
Hi,
I have clients that want music on their sites, but is there a way to
have their visitors be able to stop the music if they want.
This is what I have now:
<bgsound src="MountainDreamer.mid" loop="-1">
Thanks,
Lisa
Lisa,
I use this:
<span id="sound"></span>
<input type="button" value="Play/Stop
Music" onclick="playSound()"/>
function playSound(fname)
{
if (!fname)
var fname = "audio/minuet.mid"
var x = document.getElementById("sound")
x.innerHTML = (!x.innerHTML )
? '<embed src="' + fname + '" loop=false autostart=true
hidden>' : ''
// Following the : on the last line are two single quotes with no space
between them
// similarly look carefully at src="' (One double, one single quote)
// and '" loop= (One single, one double quote)
}
Of course, I should pass the name of the file to the function, like this
<input type="button" value="Play/Stop
Music"
onclick="playSound('audio/minuet.mid')"/>
But I made a quick fix at some stage and left it alone.
The way I have set this up, the user can both start and stop the music.
BTW, <bgsound> is an IE only feature, so <embed> is safer