The Arcive of vBulletin Modifications Site. |
|
|
#1
|
|||
|
|||
|
Hi everyone,
I need some help from a Javascript expert. I want to give users the option of turning on and off a background sound file. I need it to be off by default. This is the code I have so far and it works except for the default. It is defaulting to on as opposed to off. Code:
<BODY>
<BGSOUND id=BGSOUND_CTRL src="water.mp3">
<script type="text/javascript">
var flip = "Stop Ambiance";
function toggle() {
if (flip == "Stop Ambiance") {
flip = "Start Ambiance";
document.all['BGSOUND_CTRL'].src=""
str ='<input name="dUit" type="button" value="Start Ambiance" ';
str+='class="midCtrl" onclick="toggle();">';
document.getElementById('midCtrl').innerHTML=str;
}
else {
flip = "Stop Ambiance";
document.all['BGSOUND_CTRL'].src="water.mp3"
str ='<input name="dUit" type="button" value="Stop Ambiance"';
str+='class="midCtrl" onclick="toggle();">';
document.getElementById('midCtrl').innerHTML=str;
}
}
</script>
<div id="midCtrl" class="midCtrl">
<input name="dUit" type="button" class="midCtrl" value="Stop Ambiance" onclick="toggle();">
</div>
Thanks in advance! |
![]() |
|
|
| X vBulletin 3.8.12 by vBS Debug Information | |
|---|---|
|
|
More Information |
|
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|