document.title = ("hello → goodbye");
This is not outputting the arrow: "→" as it should. How does one escape that so it does?
You don't need to escape it at all.
Just write
document.title = "hello → goodbye";
(and make sure your file is UTF8)
If you really want to escape it, you can use a Javsacript escape code: "\u2192"
Entities are only used in HTML source; you cannot use them in ordinary strings. (Except for innerHTML
, which is HTML source)
You need to use the JavaScript character escape sequence \u2192
:
document.title = "hello \u2192 goodbye";
Or, as SLaks points out, if the JavaScript file is in Unicode, you can put it directly in the code:
document.title = ("hello → goodbye");
I don't believe the HTML <title>
tag permits mark-up at all, it just treats everything as a string literal. In other words, don't try to use HTML entities in your script, just use the actual "→" character.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With