By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,089 Members | 2,226 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,089 IT Pros & Developers. It's quick & easy.

onload music

P: 11
I am trying to set up my website so that our jingle plays when you load the page, but as I am new to web development, I do not know how. I taught myself how to use Dreamweaver CS3, which means that I don't know all that much, escpecially about Javascript. Can anybody explain how to get music to play onload in terms that a newbie can understand?

Thanks,
Daniel
Jan 31 '08 #1
Share this Question
Share on Google+
8 Replies


Death Slaught
100+
P: 1,137
Here's a script I got 133 days ago from acoder :).

Expand|Select|Wrap|Line Numbers
  1. function play() {
  2. embed = document.createElement("embed");
  3. embed.setAttribute("src", "soundfile.wav");
  4. embed.setAttribute("hidden", true);
  5. embed.setAttribute("autostart", true);
  6. document.body.appendChild(embed);
  7. }
  8.  


Just change the part the says 'soundfile.wav' to source of your sound file. And just in case you don't know where to put JavaScript you could do it like this.


[HTML] <head>
<script type="text/javascript" src="script.js"></script>
</head>


<body onload="play()">
</body>
[/HTML]

And save the JavaScript in it's own file name 'script.js'.

^_^ Hope it helps, Thanks, Death
Jan 31 '08 #2

P: 11
Death,

Thanks, I really appreciate it. I saw your thread, but I didn't really understand what I should do with it. You have cleared it up for me.

Thanks,
Daniel
Jan 31 '08 #3

P: 11
I have a new problem, now. I put the script in my site, tested it in a couple of browsers, and it worked fine. Uploaded the new page to my site, and it doesn't work. Any ideas?

Thanks,
Daniel
Jan 31 '08 #4

acoder
Expert Mod 15k+
P: 16,027
Post the page code. Have you linked to any script files that you forgot to upload?
Feb 1 '08 #5

P: 11
Post the page code. Have you linked to any script files that you forgot to upload?
Thanks, I found it. Stupid mistake on my part. I appreciate it.

Daniel
Feb 1 '08 #6

acoder
Expert Mod 15k+
P: 16,027
Glad to hear that you managed to fix it.
Feb 2 '08 #7

P: 1
I am using this code and am having a problem with it. I use exactly what is posted earlier and can't get it to work in Firefox. Any ideas? Thanks
Feb 7 '08 #8

acoder
Expert Mod 15k+
P: 16,027
I am using this code and am having a problem with it. I use exactly what is posted earlier and can't get it to work in Firefox. Any ideas? Thanks
Welcome to TSDN!

Do you get any errors? Post a test link if you have one available.
Feb 7 '08 #9

Post your reply

Sign in to post your reply or Sign up for a free account.