Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Numbers in html container id


I've found that the player doesn't work properly if id starts with any digit. e.g. this one works file <div id='videoContainerId'></div>, but this doesn't <div id='123videoContainerId'></div>. Actually the player initializes a video, but there is no control elements on it. Anyone experienced the same issue?


jwplayer('videoContainerId').setup({
file: "http://www.youtube.com/watch?v=pQqpL6n4gvU",
width: '300px'
});
jwplayer('123someId').setup({
file: "http://www.youtube.com/watch?v=pQqpL6n4gvU",
width: '300px'
});

http://jsfiddle.net/YgjYW/190/

5 Community Answers

jherrieven

User  
0 rated :

Yes.

It's generally bad practise to start an ID attribute with a number - nothing to do with JW Player specifically.

James

MisterNeutron

User  
0 rated :

More than just bad practice. The HTML4 standards say that an ID may NOT start with a digit. HTML5 allows it, but It may break a lot of different things, depending upon the browser. That will probably change eventually, but until the browsers catch up, best not to do it.

evinak

User  
0 rated :

I'm using HTML5, so that should not be an issue.

http://www.w3.org/TR/html5/dom.html#the-id-attribute

It says: in particular, IDs can consist of just digits, start with a digit, start with an underscore, consist of just punctuation, etc.

It seems me I understand the root of this issue, jwplayer uses ids for CSS styling where it needs to be escaped to work properly...

Anyway, I used PHP uniqid() to generate ids and wasted a day to find out that issue. Also there is no any information in documentation about this limitation.

[JWPlayer Team]: Would be good to mention about that limitation somewhere in docs or manuals.

MisterNeutron

User  
0 rated :

It doesn't matter whether you're using HTML5 - most browsers still choke on ID's that start with a digit. Just don't do it.

This is NOT an issue with JW Player - this is a browser problem.

MisterNeutron

User  
0 rated :

A little demo: http://misterneutron.com/digitID/

This is loused up in every browser.

I'd be curious to know what kind of "escaping" you think would solve the problem. Remember, you escape characters when you want to tell the browser, "I really, really mean it - I want this character here." But that's not the problem in this case. That leading "1" on the div ID really is a "1," and the browser is correctly reading it as a "1."

This question has received the maximum number of answers.