|
|
||||||||||||
Stopping SoundQuestion: How do I write a JavaScript function that stops playing sound?
Answer:
If you've opened a separate sound control window using the code
To be able to stop playing sound from JavaScript,
you'll need to use the techniques described in
Example 2.
mySound.mid
specified by the
BGSOUND
tag
<BGSOUND ID="BGSOUND_ID" SRC="mySound.mid">To stop playing the sound, you can use this code: document.all['BGSOUND_ID'].src='jsilence.mid'
Here jsilence.mid
is a "do-nothing" sound file - it does not play
any sound at all.
Now assume that Netscape Navigator
is playing the sound
<EMBED NAME="mySound" SRC="mySound.mid" LOOP=FALSE AUTOSTART=FALSE HIDDEN=TRUE MASTERSOUND>Then you can use the following code to stop the playback: document.mySound.stop()
JavaScripter.net.
Copyright
© 1999-2006, Alexei Kourbatov
|
||||||||||||