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:
增加了问题为什么▶HTML符号不是在文档工作。标题,当我使用正确转义的javascript十六进制值将play符号添加到文档标题时,符号似乎被压扁了:
JavaScript:
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.
看看这个小提琴的工作模式。我已经添加了/show/light,因此javascript实际上可以访问主页上的文档标题,但是如果去掉扩展,也可以看到代码。
jsFiddle
This appears to be happening on all major browsers (Chrome, Firefox, IE).
这似乎发生在所有主要浏览器(Chrome, Firefox, IE)上。
Tested (on Win8) in:
测试(Win8中的):
- Chrome: version 30.0
- 铬:30.0版本
- Firefox: version 22.0
- Firefox:22.0版本
- IE: version 10.0
- 即:10.0版本
When I go to YouTube, it looks fine, so I'm not positive it's a Browser Specific Issue.
当我去YouTube时,它看起来很好,所以我不确定这是一个浏览器特有的问题。
1 个解决方案
#1
6
By Pasting the symbol that YouTube uses (▶) into codepoints.net, 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
)
粘贴YouTube所使用的符号(▶)到codepoints.net,你可以看到,他们实际上是使用不同的unicode版本。返回的字符是U+25B6(不要与25B8和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
#1
6
By Pasting the symbol that YouTube uses (▶) into codepoints.net, 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
)
粘贴YouTube所使用的符号(▶)到codepoints.net,你可以看到,他们实际上是使用不同的unicode版本。返回的字符是U+25B6(不要与25B8和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:
演示: