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

javascript audio player

P: 316
hi all

my friend e-mailed me this quesion, i am more of a php person so i would appreciate it if you could help me look smart here is the quetsion
I am trying to write a simple script to play audio files for this guys
website and i need some help.

in the <head> if have:
Expand|Select|Wrap|Line Numbers
  1. /<script language="javascript">
  2. function player(source)
  3. {
  4. document.player.hidden(false);
  5. document.player.src(source);
  7. }
  8. </script>
/In the <body> i have:
Expand|Select|Wrap|Line Numbers
  1. /<embed src="" loop=false name="player" controls=console hidden=true>
/And then later:
Expand|Select|Wrap|Line Numbers
  1. /<a href="#top" onClick="player("audio/01.mp3")">Play</a>
/It does nothing, like it doesn't even go into the function... Its been
so long since i have used javascript, its probably a simple problem. I
attached a copy of the html file. If you could take a look at it i would
appreciate it.

now i know that with the <a ...> tag that calls the javascript he could have just used the onclick, don't know why he didn't but i have changed that in another place but still it won't work.

thanks for any assistance

Feb 15 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 5K+
P: 5,058

At first glance...
[HTML]<a href="#top" onClick="player("audio/01.mp3")">Play</a>[/HTML]

Double quote marks to open the onClick value, and then the double quotes in the function parameter will cause the value of onClick to be
"player(" and you would get a js error.

[HTML]<a href="#top" onClick="player('audio/01.mp3')">Play</a>[/HTML]
Feb 16 '07 #2

Post your reply

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