The play character (▶) is compressed in the .title document

Adding to the question of Why the HTML character for ▶ does not work in the document.title file , when I add a play character to the document title using the correct javascript hex value, the character seems to be spread:

JavaScript:

document.title = '\u25BA' + document.title; 

Inside the page (correct)

Bodydemo

Inside the header (not so right)

TitleDemo

See this script for a working model. I added /show/light so that javascript can actually access the document title on the main page, but if you remove the extension, you will also see the code.

jsFiddle

This is similar to all major browsers (Chrome, Firefox, IE).

Tested (on Win8) in:

  • Chrome: version 30.0
  • Firefox: Version 22.0
  • IE: version 10.0

When I go to YouTube, everything looks fine, so I'm not sure if this is a browser problem.

YouTubeDemo

+4
source share
1 answer

By inserting the character that YouTube uses (▶) into codepoints.net , you can see that they are actually using a different version of Unicode. Return character U+25B6 (not to be confused with 25B8 and 25BA )

This should look better:

 function PrependPageTitle(player) { var playIcon = '\u25B6 '; var startsWithIcon = document.title.substring(0, playIcon.length)===playIcon; if (player.paused && startsWithIcon) { document.title = document.title.slice(playIcon.length); } else if (!player.paused && !startsWithIcon) { document.title = playIcon + document.title; } } 

Demo here:

jsFiddle

+6
source

Source: https://habr.com/ru/post/1484555/


All Articles