We have JavaScript that writes to the document title and attempts to pad it with extra spaces...
document.title = "My Title "
But this gets translated to "My Title  "
Anyone know how to prevent this?
We have JavaScript that writes to the document title and attempts to pad it with extra spaces...
document.title = "My Title "
But this gets translated to "My Title  "
Anyone know how to prevent this?
The document.title property is a normal string that is not HTML-encoded.
You should set it to "My Title ".
However, the browser may strip the spaces itself; there is nothing you can do about that.
is an HTML entity reference that represents the character reference   (see list of entities in HTML 4) that again represents the Unicode character U+00A0. Now document.title is of the type DOMString that is similar to CDATA that’s value is not parsed. That means you cannot use HTML references for document.title as the value is not parsed as HTML.
Try Javascript’s Unicode escape sequences to denote these character like this:
document.title = "My Title\u00A0\u00A0"