admin管理员组

文章数量:1332395

Adding to the question on Why does the HTML symbol for ▶ not work in document.title, when I add the play symbol to the document title using the properly escaped javascript hex value, the symbol seems squished:

JavaScript:

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

Inside Page (correct)

Inside Title (not so correct)

See this fiddle for a working model. I've added /show/light so the javascript can actually access the document title on the main page, but if you take off the extension, you can see the code as well.

jsFiddle

This appears to be happening on 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, it looks fine, so I'm not positive it's a Browser Specific Issue.

Adding to the question on Why does the HTML symbol for ▶ not work in document.title, when I add the play symbol to the document title using the properly escaped javascript hex value, the symbol seems squished:

JavaScript:

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

Inside Page (correct)

Inside Title (not so correct)

See this fiddle for a working model. I've added /show/light so the javascript can actually access the document title on the main page, but if you take off the extension, you can see the code as well.

jsFiddle

This appears to be happening on 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, it looks fine, so I'm not positive it's a Browser Specific Issue.

Share Improve this question edited May 23, 2017 at 12:01 CommunityBot 11 silver badge asked Oct 14, 2013 at 4:12 KyleMitKyleMit 30.4k72 gold badges510 silver badges701 bronze badges 3
  • Maybe because the font is based on the OS/Browser? It seems to be displaying fine on Chromium+Ubuntu. Can you include the OS/Browser so we can check accordingly? – godfrzero Commented Oct 14, 2013 at 4:17
  • I've noticed the effect in Firefox with YouTube. on Windows. I've assumed it was an OS font issue and beyond the scope of anything that you could control in CSS or JavaScript – Jason Sperske Commented Oct 14, 2013 at 4:17
  • If nothing else works properly throughout all environments, you could probably try changing the favicon dynamically instead. – godfrzero Commented Oct 14, 2013 at 4:22
Add a ment  | 

1 Answer 1

Reset to default 6

By Pasting the symbol that YouTube uses (▶) into codepoints, you can see that they are actually using a different unicode version. The character returned is 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

本文标签: javascriptPlay symbol (▶) squished in documenttitleStack Overflow