Firefox JavaScript parameters passed to function are undefined on event
up vote
0
down vote
favorite
I see some questions previously asked on this topic but have either not been answered or I don't understand the answer.
Why does the following work in ALL browsers except FireFox? When the onplay()
event fires, the parameter passed is undefined
.
<html>
<head><title></title>
</head>
<body>
<audio id="audioplayer" name="player1" preload="none" onplay="audioStarted(audioplayer[0]);" src="http://kerkradio.co.za:8000/audio/beste-luisteraar.mp3?a=1" controls> </audio><br/>
<audio id="audioplayer" name="player2" preload="none" onplay="audioStarted(audioplayer[1]);" src="http://kerkradio.co.za:8000/audio/beste-luisteraar.mp3?a=2" controls> </audio><br/>
<audio id="audioplayer" name="player3" preload="none" onplay="audioStarted(audioplayer[2]);" src="http://kerkradio.co.za:8000/audio/beste-luisteraar.mp3?a=3" controls> </audio><br/>
<audio id="audioplayer" name="player4" preload="none" onplay="audioStarted(audioplayer[3]);" src="http://kerkradio.co.za:8000/audio/beste-luisteraar.mp3?a=4" controls> </audio><br/>
</body>
<script>
function audioStarted(thePlayer) alert(thePlayer.src);
</script>
</html>
javascript firefox undefined
add a comment |
up vote
0
down vote
favorite
I see some questions previously asked on this topic but have either not been answered or I don't understand the answer.
Why does the following work in ALL browsers except FireFox? When the onplay()
event fires, the parameter passed is undefined
.
<html>
<head><title></title>
</head>
<body>
<audio id="audioplayer" name="player1" preload="none" onplay="audioStarted(audioplayer[0]);" src="http://kerkradio.co.za:8000/audio/beste-luisteraar.mp3?a=1" controls> </audio><br/>
<audio id="audioplayer" name="player2" preload="none" onplay="audioStarted(audioplayer[1]);" src="http://kerkradio.co.za:8000/audio/beste-luisteraar.mp3?a=2" controls> </audio><br/>
<audio id="audioplayer" name="player3" preload="none" onplay="audioStarted(audioplayer[2]);" src="http://kerkradio.co.za:8000/audio/beste-luisteraar.mp3?a=3" controls> </audio><br/>
<audio id="audioplayer" name="player4" preload="none" onplay="audioStarted(audioplayer[3]);" src="http://kerkradio.co.za:8000/audio/beste-luisteraar.mp3?a=4" controls> </audio><br/>
</body>
<script>
function audioStarted(thePlayer) alert(thePlayer.src);
</script>
</html>
javascript firefox undefined
You have multiple elements with the sameid
, which is invalid, and you're passing a variable that's undefined in the code you show, and you're trying to access a property of that variable. What are you trying to do?
– David Thomas
Nov 10 at 7:48
Hi Thomas. I am aware of the multiple elements with the same name, hence passing the index counter i.e. audioplayer[0]. Works very well except in FireFox. Have a look at what I am really trying to accomplish here: kerkradio.co.za The code example just simplified what the problem is.
– Sytze Visser
Nov 10 at 9:11
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I see some questions previously asked on this topic but have either not been answered or I don't understand the answer.
Why does the following work in ALL browsers except FireFox? When the onplay()
event fires, the parameter passed is undefined
.
<html>
<head><title></title>
</head>
<body>
<audio id="audioplayer" name="player1" preload="none" onplay="audioStarted(audioplayer[0]);" src="http://kerkradio.co.za:8000/audio/beste-luisteraar.mp3?a=1" controls> </audio><br/>
<audio id="audioplayer" name="player2" preload="none" onplay="audioStarted(audioplayer[1]);" src="http://kerkradio.co.za:8000/audio/beste-luisteraar.mp3?a=2" controls> </audio><br/>
<audio id="audioplayer" name="player3" preload="none" onplay="audioStarted(audioplayer[2]);" src="http://kerkradio.co.za:8000/audio/beste-luisteraar.mp3?a=3" controls> </audio><br/>
<audio id="audioplayer" name="player4" preload="none" onplay="audioStarted(audioplayer[3]);" src="http://kerkradio.co.za:8000/audio/beste-luisteraar.mp3?a=4" controls> </audio><br/>
</body>
<script>
function audioStarted(thePlayer) alert(thePlayer.src);
</script>
</html>
javascript firefox undefined
I see some questions previously asked on this topic but have either not been answered or I don't understand the answer.
Why does the following work in ALL browsers except FireFox? When the onplay()
event fires, the parameter passed is undefined
.
<html>
<head><title></title>
</head>
<body>
<audio id="audioplayer" name="player1" preload="none" onplay="audioStarted(audioplayer[0]);" src="http://kerkradio.co.za:8000/audio/beste-luisteraar.mp3?a=1" controls> </audio><br/>
<audio id="audioplayer" name="player2" preload="none" onplay="audioStarted(audioplayer[1]);" src="http://kerkradio.co.za:8000/audio/beste-luisteraar.mp3?a=2" controls> </audio><br/>
<audio id="audioplayer" name="player3" preload="none" onplay="audioStarted(audioplayer[2]);" src="http://kerkradio.co.za:8000/audio/beste-luisteraar.mp3?a=3" controls> </audio><br/>
<audio id="audioplayer" name="player4" preload="none" onplay="audioStarted(audioplayer[3]);" src="http://kerkradio.co.za:8000/audio/beste-luisteraar.mp3?a=4" controls> </audio><br/>
</body>
<script>
function audioStarted(thePlayer) alert(thePlayer.src);
</script>
</html>
javascript firefox undefined
javascript firefox undefined
asked Nov 10 at 7:45
Sytze Visser
61
61
You have multiple elements with the sameid
, which is invalid, and you're passing a variable that's undefined in the code you show, and you're trying to access a property of that variable. What are you trying to do?
– David Thomas
Nov 10 at 7:48
Hi Thomas. I am aware of the multiple elements with the same name, hence passing the index counter i.e. audioplayer[0]. Works very well except in FireFox. Have a look at what I am really trying to accomplish here: kerkradio.co.za The code example just simplified what the problem is.
– Sytze Visser
Nov 10 at 9:11
add a comment |
You have multiple elements with the sameid
, which is invalid, and you're passing a variable that's undefined in the code you show, and you're trying to access a property of that variable. What are you trying to do?
– David Thomas
Nov 10 at 7:48
Hi Thomas. I am aware of the multiple elements with the same name, hence passing the index counter i.e. audioplayer[0]. Works very well except in FireFox. Have a look at what I am really trying to accomplish here: kerkradio.co.za The code example just simplified what the problem is.
– Sytze Visser
Nov 10 at 9:11
You have multiple elements with the same
id
, which is invalid, and you're passing a variable that's undefined in the code you show, and you're trying to access a property of that variable. What are you trying to do?– David Thomas
Nov 10 at 7:48
You have multiple elements with the same
id
, which is invalid, and you're passing a variable that's undefined in the code you show, and you're trying to access a property of that variable. What are you trying to do?– David Thomas
Nov 10 at 7:48
Hi Thomas. I am aware of the multiple elements with the same name, hence passing the index counter i.e. audioplayer[0]. Works very well except in FireFox. Have a look at what I am really trying to accomplish here: kerkradio.co.za The code example just simplified what the problem is.
– Sytze Visser
Nov 10 at 9:11
Hi Thomas. I am aware of the multiple elements with the same name, hence passing the index counter i.e. audioplayer[0]. Works very well except in FireFox. Have a look at what I am really trying to accomplish here: kerkradio.co.za The code example just simplified what the problem is.
– Sytze Visser
Nov 10 at 9:11
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
That it works at all (which I guess it might) is an aberration brought about from javascript's weird hoisting of id's to the global scope (making getElementById oddly redundant). Firefox is quite right to cough this code back up, and I'd be surprised if it really were the case that it works in all other browsers
Try passing the keyword this
instead of that audioplayer[n] jive - yours is the sort of situation that this
was designed to handle
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
That it works at all (which I guess it might) is an aberration brought about from javascript's weird hoisting of id's to the global scope (making getElementById oddly redundant). Firefox is quite right to cough this code back up, and I'd be surprised if it really were the case that it works in all other browsers
Try passing the keyword this
instead of that audioplayer[n] jive - yours is the sort of situation that this
was designed to handle
add a comment |
up vote
0
down vote
That it works at all (which I guess it might) is an aberration brought about from javascript's weird hoisting of id's to the global scope (making getElementById oddly redundant). Firefox is quite right to cough this code back up, and I'd be surprised if it really were the case that it works in all other browsers
Try passing the keyword this
instead of that audioplayer[n] jive - yours is the sort of situation that this
was designed to handle
add a comment |
up vote
0
down vote
up vote
0
down vote
That it works at all (which I guess it might) is an aberration brought about from javascript's weird hoisting of id's to the global scope (making getElementById oddly redundant). Firefox is quite right to cough this code back up, and I'd be surprised if it really were the case that it works in all other browsers
Try passing the keyword this
instead of that audioplayer[n] jive - yours is the sort of situation that this
was designed to handle
That it works at all (which I guess it might) is an aberration brought about from javascript's weird hoisting of id's to the global scope (making getElementById oddly redundant). Firefox is quite right to cough this code back up, and I'd be surprised if it really were the case that it works in all other browsers
Try passing the keyword this
instead of that audioplayer[n] jive - yours is the sort of situation that this
was designed to handle
answered Nov 10 at 10:07
lucas
850717
850717
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53237010%2ffirefox-javascript-parameters-passed-to-function-are-undefined-on-audio-event%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You have multiple elements with the same
id
, which is invalid, and you're passing a variable that's undefined in the code you show, and you're trying to access a property of that variable. What are you trying to do?– David Thomas
Nov 10 at 7:48
Hi Thomas. I am aware of the multiple elements with the same name, hence passing the index counter i.e. audioplayer[0]. Works very well except in FireFox. Have a look at what I am really trying to accomplish here: kerkradio.co.za The code example just simplified what the problem is.
– Sytze Visser
Nov 10 at 9:11