I have a frameset with a header and a main frame. The main frame’s page’s body onload event launches an embedded sound file with buttons on that page to start and stop the sound. What I’m looking for is a way to stop the sound when the header frame’s page is clicked.
The script in the main page is:
[code]
<body onLoad=”playSound()”>
<BGSOUND id=”BGSOUND_ID” LOOP=1 SRC=”jsilence.mid”>
<EMBED NAME=”coe” SRC=”coe_start.mp3″
LOOP=FALSE AUTOSTART=FALSE HIDDEN=TRUE MASTERSOUND>
<script language=”JavaScript”>
<!–
ver=parseInt(navigator.appVersion)
ie4=(ver>3 && navigator.appName!=”Netscape”)?1:0
ns4=(ver>3 && navigator.appName==”Netscape”)?1:0
ns3=(ver==3 && navigator.appName==”Netscape”)?1:0
function playSound() {
if (ie4) document.all[‘BGSOUND_ID’].src=’coe_start.mp3′;
if ((ns4||ns3)
&& navigator.javaEnabled()
&& navigator.mimeTypes[‘audio/x-midi’]
&& self.document.coe.IsReady()
)
{
self.document.coe.play()
}
}
function stopSound() {
if (ie4) document.all[‘BGSOUND_ID’].src=’jsilence.mid’;
if ((ns4||ns3)
&& navigator.javaEnabled()
&& navigator.mimeTypes[‘audio/x-midi’]
)
{
self.document.coe.stop()
}
}
The following script is what I’ve tried in the header page, but it doesn’t work.
<head>
<script type=”text/javascript”><!–
function stopSound(){
main.document.coe.stop();
}
if(document.getElementsByTagName) onload = function(){
document.getElementsByTagName(“BODY”)[0].onclick = stopSound;
}
</script>
</head>
Any suggestions will be greatly appreciated.
Thanks