Terry,
Your point is quite valid, whcih is why I have been trying to acheive just
this option - either to play or not to play the music.
It took me a lot of trial and error before I got it right. (See other
threads on the topic.)
This is the code I came up with, which works in both IE6 and Firefox - and
hopefully other browsers as well
function playSound()
{ document.getElementById("sound").innerHTML= '<embed src="minuet.wav"
loop=false autostart=true hidden>' }
function stopSound()
{ document.getElementById("sound").innerHTML= ''}
<span id="sound"></span>
<input type="button" value="Play
Music" onClick="playSound()">
<input type="button" value="Stop
Music" onClick="stopSound()">
All other attempts failed in Firefox. This one worked.
So, for anyone wanting to add music, please feel freee to copy this so as to
give the visitor the choice.
--
Cheers,
Trevor L.
Website:
http://tandcl.homemail.com.au
Terry said:
I never cease to wonder why people think automatic background sound on
a website is a "good thing."
Instead of generating a sound and allowing the user to turn it off
(or, as I do, leave the website!), why don't you create a quiet
website and let the user click on a button to play the music.
--
Terry
My blog:
http://www.TheNextWindow.com
My home theater site:
http://www.TerrysHomeTheater.com
My tip site and newsletter:
http://www.TerrysComputerTips.com
Mark,
At the moment I use a cookie to control playing music on entry. If
the cookie is not set, the music plays.
Otherwise,otherwise. So I thought I'd try the suggestion in the link
you gave.
This is my code:
<embed src="minuet.mid" id="theNoise" name="theNoise"
width="144" height="45" autostart="true" loop="false">
<input type="button" value="Stop
Sound"
onClick="document.all['theNoise'].src='jsilence.mid'">
where jsilence.mid is just an empty file
The msuic plays fine, but pressing the "Stop Sound" button does
nothing.
I am using IE6.
Any ideas anyone?