470,863 Members | 1,389 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,863 developers. It's quick & easy.

javascript audio player

316 100+
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);
  6. document.player.play(true);
  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
1 5932
5,058 Expert 4TB

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.

Similar topics

1 post views Thread by Ron Provost | last post: by
1 post views Thread by ray well | last post: by
1 post views Thread by richardscheff | last post: by
reply views Thread by Terry Olsen | last post: by
4 posts views Thread by =?Utf-8?B?U2F0eWE=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.