Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set » HTML entity in JavaScript's document.title?

I'm setting document.title with JavaScript, and I can't find a way to supply » (&raquo) without it appearing as literal text.

Here's my code:

document.title = 'Home » site.com'; 

If I use &raquo ; in the title tag of the document it works great and displays correctly as », but it seems to be unescaping when I include it in document.title.

Any ideas?

thanks!

like image 959
Richard Avatar asked Jun 01 '11 14:06

Richard


People also ask

Is the set open today?

The Stock Exchange of Thailand is open Monday through Friday from 10:00 am to 12:30 pm and 2:30 pm to 4:30 pm Indochina Time (GMT+07:00).

What is stock set?

What is SETS? Stock Exchange Electronic Trading Service (SETS) is London Stock Exchange's flagship electronic order book, trading FTSE 100, FTSE 250, FTSE Small Cap Index constituents, Exchange Traded Funds (ETFs) and Exchange Traded Products (ETPs), plus other liquid AIM, Irish and London Standard-listed securities.

Does Thailand have stock market?

Founded on 30 April 1975, it is ASEAN's 2nd largest after Singapore and the world's 23rd by market capitalization at US$564 billion (both SET and mai) as of 9 May 2022.


2 Answers

document.title takes the string as it is, so you can do this:

document.title = 'Home » site.com';

If you need to provide it as the entity name, you can set the innerHTML attribute. Here are two examples of how you can do it.

document.getElementsByTagName('title')[0].innerHTML = '»';
// or
document.querySelector('title').innerHTML = "»";
like image 71
htanata Avatar answered Sep 22 '22 11:09

htanata


Try

document.title = 'Home \u00bb site.com';

Generally you can look up your special character at a site like this and then, once you know the numeric code, you can construct a Unicode escape sequence in your JavaScript string. Here, that character is code 187, which is "bb" in hex. JavaScript Unicode escapes look like "\u" followed by 4 hex digits.

like image 22
Pointy Avatar answered Sep 20 '22 11:09

Pointy