Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2003
    Location
    Vancouver Island Canada
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Play MP3 on load

    I need a script to play an MP3 file onloading a webpage. Right now I use bgsound in the body tag and it works fine, but what I'd like is for the file to play only once using a cookie (I have the cookie script) and then disableing the mp3 after the cookie is set. Is there a function I can use to play an MP3 file? The page is at www.rebeccaandthereplacements.com All help will be greatly appreciated.

  • #2
    Regular Coder
    Join Date
    Mar 2004
    Posts
    138
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I don't really get what you're saying. Right now, it plays only once so why do you need it to work with a cookie?

  • #3
    Regular Coder
    Join Date
    Nov 2003
    Location
    Vancouver Island Canada
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I want to disable the mp3 with a cookie because if the user goes to another page and then returns I don't want them to have to listen to the intro again.

  • #4
    Regular Coder
    Join Date
    Nov 2003
    Location
    Vancouver Island Canada
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Resolved

    I've resolved my problem by using an create element function then running the function if the cookie is not present.
    function play()
    {

    var sound1 = document.createElement('embed');

    with(sound1)
    {
    setAttribute('src','Music/Intro.mp3');
    setAttribute('autostart', 'true');
    setAttribute('hidden', 'true');
    setAttribute('loop', '0');
    }

    document.body.appendChild(sound1);
    }
    If anyone wants to see the entire code go to
    http://lantzvillecomputers.ca/R&RPic...Site/Index.htm
    I have a test site there. I would appreciate it if someone running Netscape could give it a test and tell me if it works. Thanks


  •  

    Posting Permissions

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