...

View Full Version : Play MP3 on load



glenmac
03-17-2004, 11:51 PM
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.

MattJakel
03-18-2004, 02: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?

glenmac
03-18-2004, 04: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.

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

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&RPics/RebeccasSite/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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum