Question

I would have expected that the page title respected the charset, but I'm seeing differently. Setting document.title to Fo'o Bar doesn't result in Fo'o Bar being printed as the page title. My browser encoding is set to UTF-8, I am declaring the charset in a meta tag, and the file is saved as UTF-8. It seems like my only option is to use JavaScript to create a DOM node and then set the document.title to the text from that node. Is this right?

Était-ce utile?

La solution

Set your title like this:

document.title = 'Fo\u0027o Bar';

See the MDN for full documentation on escaping Unicode characters.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top