Results 1 to 7 of 7

Thread: ON/OFF Music script not working in IE

  1. #1
    Join Date
    Dec 2008
    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default ON/OFF Music script not working in IE

    So I have been trying to use this script by John Sheuer for bg music. It works great except in IE. I have tried a hundred different ways, but can't seem to get it working in IE. I have looked back through the other threads on the subject to no avail. Any help out there?

    Here is what I have:

    Code:
    <script type="text/javascript">
    		/*Toggle Sound Script © 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="HomePage/Mixdown.mp3"  //Set to name and path of your sound file
    function toggleSound(){
    if (document.all&&document.all.sound&&document.all.sound.src!=='')
    document.all.sound.src=''
    else if (document.getElementById&&document.getElementById('snd')){
    sndEl=document.getElementById('snd')
    document.getElementById('sndC').removeChild(sndEl)
    }
    else if (document.all&&document.all.sound&&document.all.sound.src=='')
    document.all.sound.src=sndEl
    else if (document.getElementById)
    document.getElementById('sndC').appendChild(sndEl)
    }
    </script>
    Code:
    <script type="text/javascript">
    if(document.getElementById&&!document.getElementById('sound')){
    document.write('<div id="sndC" style="position:absolute;top:-1000px:left:-1000px;visibility:hidden;">')
    								
    document.write('<embed id="snd" type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" Name="MediaPlayer" src="'+sndEl+'" AUTOSTART="true" hidden="true" loop="true">')
    
    document.write('</div>')
    }
    document.write('<input type="image" class="centerd" src="HomePage/Music.gif" onclick="toggleSound();">')
    </script>
    Thanks,

    Andrew

  2. The Following User Says Thank You to jaiantbass For This Useful Post:

    moscarda (02-07-2009)

  3. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    That's one of the earlier versions of the code. It had at least several updates over the years as browsers changed. And, although I haven't revisited this concept in a while, the last installment is still working fine in IE:

    http://loisimages.com/john/music/music_adv_dd.htm

    Use your browser's 'view source' to get the code.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #3
    Join Date
    Dec 2008
    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Thanks

    Thanks John, I will give this a try.

    Andrew

  5. #4
    Join Date
    Dec 2008
    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Music not playing

    John,

    Could you take a look at what I have done here:

    www.edrafting.homeip.net

    The music won't play for some reason.

    Thanks again,

    Andrew

  6. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    First of all, you are using Swiss Army Slide Show with no credit in your page's source code. That is in violation of DD TOS:

    Your page is in violation of Dynamic Drive's usage terms, which, among other things, state that the script credit must appear in the source code of the page(s) using the script. Please reinstate the notice first.


    You may also be using other scripts (DD scripts or others) in violation of their TOS, I just happened to notice that one, perhaps because I wrote it and could easily see that it was being used.

    Please make sure that you are crediting all scripts whose Terms Of Service require it.

    That said, as for the Toggle Sound Script III script, you have an onload conflict, and you left out some code. To fix the onload conflict, get rid of this (highlighted):

    Code:
    <body onload="Load('slide');" >
    Move its code to here (also highlighted):

    Code:
    onload=function(){toggleSound(document.images.bob);
    if(document.getElementById&&document.getElementById('sndC'))
    document.getElementById('sndC').style.display='';
    if(start_music_onload){
    Load('slide');
    toggleSound(document.images.bob);
    document.images.bob.src = document.images.bob.lowsrc;
    };
    };
    As for the missing code, add it back (highlighted) here:

    Code:
     . . . kground-color:#D1E5EF;
    }
    </style>
    
    
    </head>
    
    <body>
    <!--[if IE]>
    <script type="text/javascript">
    if(mpIsInstalled)
    document.write('<object id="sound" height="0" width="0"'+
    '  classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">\n'+
    '<param name="playCount" value="20000">\n'+
    '<\/object>\n');
    else
    document.write('<bgsound id="sound" src="" loop="-1">')
    </script>
    <![endif]-->
    <div id="maincontent">
    <div id="box1" class="slide :-650:-50 . . .
    Working here in the three browsers I've tested (FF, Opera, and IE).
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #6
    Join Date
    Dec 2008
    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Sorry

    John,

    I must have accidentally deleted out the credit's. I will fix this right away, my apologies. I was just talking to someone about making sure the credits where there when using other peoples scripts (and even showed them your sound script with your credits in it). Very embarrassing on my part. Being very new to javascript, I have found that your scripts have been very easy to follow and appreciate everything. Thanks again for your help.

    Andrew

  8. #7
    Join Date
    Dec 2008
    Posts
    7
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default credits

    John,

    In my rush, I missed how to appropriately give credit when using external .js files. I left them in the original .js files but didn't realize they didn't show up in the source code. I have fixed it and thank you for correcting me.

    Andrew

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •