Hi:
I have been using the follow script for quite sometime. And just now noticed that it works well in MSIE and Chrome but in the latest Fire Fox it does play the music but the on/off switch won't work where previously it worked in all three browsers. Any ideas on how to make it work as intended in FireFox are appreciated. Thanks.
<script type="text/javascript">
/*Toggle Sound Script II © John Davenport Scheuer
as first seen in www.dynamicdrive.com/forums (user name:
jscheuer1). Visit http://www.dynamicdrive.com for 100's
of DHTML scripts. This credit must remain for legal use.
*/
var sndEl="music/claire_de_lune.mid" //Set to name and path of your sound file
var music_on="images/eyiplay.gif" //Set to image to display while music is on
var music_off="images/eyistop.gif" //Set to image to display while music is off
var active_img="images/eyispeaker.gif" //Set to image to display while image is hovered
///////////////Stop Editing///////////////
var da=document.all
var preload=[music_on, music_off, active_img]
var preloading=new Array();
for (var i_tem = 0; i_tem < preload.length; i_tem++){
preloading[i_tem]=new Image();
preloading[i_tem].src=preload[i_tem]
}
function textReveal(el, state){
var text=da? da.text : document.getElementById('text')
text.style.visibility=state=='on'? 'visible' : ''
el.src=state=='on'? active_img : el.lowsrc
}
function toggleSound(el){
var text=da? da.text : document.getElementById('text')
if (da&&da.sound&&da.sound.src!==''){
da.sound.src=''
el.lowsrc=music_off
text.innerHTML=' Music On'
}
else if (document.getElementById('snd')){
sndEl=document.getElementById('snd')
document.getElementById('sndC').removeChild(sndEl)
el.lowsrc=music_off
text.innerHTML=' Music On'
}
else if (da&&da.sound&&da.sound.src==''){
da.sound.src=sndEl
el.lowsrc=music_on
text.innerHTML=' Music Off'
}
else {
document.getElementById('sndC').appendChild(sndEl)
el.lowsrc=music_on
text.innerHTML=' Music Off'
}
}
</script>
I use the following code on the page to call it:
<!-- Begin Toggle Sound Body Code --><font color="#c0c0c0">
<!--[if IE]>
<script type="text/javascript">
document.write('<bgsound id="sound" src="'+sndEl+'" loop="-1">')
</script>
<![endif]-->
<script type="text/javascript">
if (document.getElementById&&!document.getElementById('sound')){
document.write('<div id="sndC" style="width:0;height:0;position:absolute;top:-1000px:left:-1000px;visibility:hidden;">')
document.write('<embed id="snd" style="width:0;height:0;position:absolute;top:-1000px:left:-1000px;visibility:hidden;" src="'+sndEl+'" autostart="true" hidden="true" loop="true">')
document.write('<\/div>')
}
if ((da&&da.sound)||document.getElementById)
document.write('<img style="cursorointer;" lowsrc="'+music_on+'" src="'+music_on+'" onmouseout="textReveal(this, \'off\')" onmouseover="textReveal(this, \'on\');" onclick="toggleSound(this);"><span id="text"> Music Off<\/span>')
</script>
<!-- End Toggle Sound Body Code -->
</font>



ointer;" lowsrc="'+music_on+'" src="'+music_on+'" onmouseout="textReveal(this, \'off\')" onmouseover="textReveal(this, \'on\');" onclick="toggleSound(this);"><span id="text"> Music Off<\/span>')
Reply With Quote

Bookmarks