[Javascript] The Non-Breaking Space of Doom

Triche Osborne wdlists at triche-osborne.com
Tue Jan 10 06:11:47 CST 2006


Andrew Crawford wrote:
> However, the list displays as in the first example (Example 1) when the
> select list is all hard coded in HTML.  So far, so good.
> 
> The problem appears when trying to generate the same select list with
> JavaScript.  . . .
> The label contains the text description (label) for the current option
> element.  For instance, on the second pass in the examples above label
> would be " Item-1.1"  So, it should produce output just like
> Example 2 above and, presumably, display just like Example 1.  It does not.
> 
> When JavaScript generates the select list, it displays like the second
> example above (Example 2) instead of the first (Example 1).  That is, it
> actually displays " " instead of putting a non-breaking space
> character.

I ran into a similar problem with the double left angle bracket while 
trying to append a DOM-style error message in a JavaScript class. The 
instructor told me it would be necessary to use the escaped Unicode 
equivalent for that character. It worked beautifully. You might try it 
here: It would be \u00A0 for the non-breaking space.

Triche Osborne




More information about the Javascript mailing list