Reputation:
I have been using prototype.js in a web application. I am populating some Divs dynamically, on selecting some radio buttons. Before populating contents in Div, I am clearing previous contents by using prototype's update method as -
$('item').update('');
In IE, this puts a line break automatically but not in Firefox 3.5. So, to work it in same manner as IE, I have change the code as -
$('item').update(' ');
Now, this worked for me as expected. But, generally " " is being used with a semicolon ($nbsp;). I want to know, if there can be a failure of this code. For example, is there any chances where   will be display instead of a blank space? But some browsers might be smart enough to detect the coding error by the programmer and autocorrect it.
Upvotes: 6
Views: 5578
Reputation: 18598
not sure if this will help (or change anything) but the correct syntax is actually without the single quotes:
$('element').update();
Upvotes: 0
Reputation: 391818
NEVER rely on browser autocorrection or "recommended" behavior.
If your code is wrong, then (a) it's wrong and (b) browsers are free to do inconsistent things with it.
Upvotes: 9
Reputation: 3482
I concur, Dodgy markup and JavaScript errors are a disaster for debugging any problems you have in future as you can't eliminate the dodgy markup is causing the browser to interpret code incorrectly.
Upvotes: 0
Reputation: 655209
The ending semicolon can be omited but it’s absolutely not recommended. See this note in the HTML 4 specification regarding character references:
In SGML, it is possible to eliminate the final ";" after a character reference in some cases (e.g., at a line break or immediately before a tag). In other circumstances it may not be eliminated (e.g., in the middle of a word). We strongly suggest using the ";" in all cases to avoid problems with user agents that require this character to be present.
Upvotes: 14