PDA

View Full Version : start/stop music javascript not working in opera



w2mt
07-04-2007, 01:49 PM
i am using this script to display a start/stop music button on site, but it only works with IE. in opera i do see the button but clicking on it does nothing. can yall help me out? whats wrong with code and what do i have to change? thanks!
also how can i make the same button start/stop an animation besides the music?


<BGSOUND id=BGSOUND_CTRL src="introfiles/bgmusic.wav">

<script type="text/javascript">
var flip = "Stop Music";
function toggle() {
if (flip == "Stop Music") {
flip = "Start Music";
document.all['BGSOUND_CTRL'].src=""
str ='<input name="dUit" type="button" value="Start Music" ';
str+='class="midCtrl" onclick="toggle();">';
document.getElementById('midCtrl').innerHTML=str;
}
else {
flip = "Stop Music";
document.all['BGSOUND_CTRL'].src="introfiles/bgmusic.wav"
str ='<input name="dUit" type="button" value="Stop Music"';
str+='class="midCtrl" onclick="toggle();">';
document.getElementById('midCtrl').innerHTML=str;
}
}
</script>
<div id="midCtrl" class="midCtrl">
<input name="dUit" type="button" class="midCtrl" onclick="toggle();" value="Stop Music">
</div>