View Full Version : Play MP3 on load

03-18-2004, 12:51 AM
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.

03-18-2004, 03:14 AM
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?

03-18-2004, 05:42 AM
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.

03-18-2004, 04:40 PM
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');

setAttribute('autostart', 'true');
setAttribute('hidden', 'true');
setAttribute('loop', '0');

If anyone wants to see the entire code go to
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