Results 1 to 4 of 4

Thread: MUSIC ON/OFF (in IE 7 doesn't stop)

  1. #1
    Join Date
    Apr 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default MUSIC ON/OFF (in IE 7 doesn't stop)

    Hello there

    I am trying to fix a bug in the following script as the music does not stop in IE 7 if the file is an .mp3 but does in IE 5 +6 and Firefox. I hope you can help. Thank you!


    <script type="text/javascript">

    var sound2Embed = null;

    function init() {
    }


    function sound2Play() {
    if ( !sound2Embed ) {
    sound2Embed = document.createElement("embed");
    sound2Embed.setAttribute("src", "audio/tequila.mp3");
    sound2Embed.setAttribute("hidden", true);
    sound2Embed.setAttribute("autostart", true);
    } else sound2Stop();
    sound2Embed.removed = false;
    document.body.appendChild(sound2Embed);
    }

    function sound2Stop() {
    if ( sound2Embed && !sound2Embed.removed ) {
    document.body.removeChild(sound2Embed);
    sound2Embed.removed = true;
    }
    }

    </script>


    <body onload="init();">

    <input type="submit" onclick="sound2Play();" name="Play 2" value="Play 2">

    <input type="submit" onclick="sound2Stop();" name="Stop 2" value="Stop 2">

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,192 Times in 3,155 Posts
    Blog Entries
    12

    Default

    You might want to read this thread:

    http://www.dynamicdrive.com/forums/s...ead.php?t=6796

    But you might want to read the whole thing before deciding which code to use, and as mentioned in that thread, there is always Flash. The thread is so long in terms of time, that some of the earliest code may be outdated. As I recall, I revisited that thread several times each time a user started having trouble with the code and reported it.
    - John
    ________________________

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

  3. #3
    Join Date
    Apr 2007
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Music on/off .mp3 won't work in FF

    Thanks for your reply.

    Just for yuor information I have checked the thread but it does not work with .mp3 files in FF.


  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,926
    Thanks
    43
    Thanked 3,192 Times in 3,155 Posts
    Blog Entries
    12

    Default

    Are you sure you used the latest version in that thread? It worked here for that:

    Please post a link to the page on your site that contains the problematic code so we can check it out.
    - John
    ________________________

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

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
  •