admin管理员组

文章数量:1335371

I have a robust title for web-crawlers etc... L.A. Takedown // The Band - bla bla... ~ but for style - I want a cool looking page title. I want the favicon to be the LA logo...

I create a new title for the page... nerd alert

var newTitle = ' Takedown';

Then, inserting it like this...

document.title = newTitle;

Then I get this:

I am very pleased with this... but I would love a little space before the 'Takedown' string / which is something I should understand in general...

It seems like strings just do this: ( I mean... strip the space at the beginning and end)

But I can add   and replace the spaces for markup... but the document / browser tab isn't down with that...

So, why is this string having it's spaces stripped... '__Takedown' - and how can I force a space in there... ??? - in a non-markup situation?

Here is the CodePen breakdown of the ideas so far... and @moogs idea works in theory --- but the tab still doesn't reflect even though the spaces appear in the head as seen here ->

If your answer is "the space doesn't matter - it's fine how it is..." or something like that.. just save yourself some time and don't reply. This is just an example.


This is what I want to happen...

I have a robust title for web-crawlers etc... L.A. Takedown // The Band - bla bla... ~ but for style - I want a cool looking page title. I want the favicon to be the LA logo...

I create a new title for the page... nerd alert

var newTitle = ' Takedown';

Then, inserting it like this...

document.title = newTitle;

Then I get this:

I am very pleased with this... but I would love a little space before the 'Takedown' string / which is something I should understand in general...

It seems like strings just do this: http://codepen.io/sheriffderek/pen/YXxyqQ ( I mean... strip the space at the beginning and end)

But I can add   and replace the spaces for markup... but the document / browser tab isn't down with that...

So, why is this string having it's spaces stripped... '__Takedown' - and how can I force a space in there... ??? - in a non-markup situation?

Here is the CodePen breakdown of the ideas so far... and @moogs idea works in theory --- but the tab still doesn't reflect even though the spaces appear in the head as seen here ->

If your answer is "the space doesn't matter - it's fine how it is..." or something like that.. just save yourself some time and don't reply. This is just an example.


This is what I want to happen...

Share Improve this question edited Jun 15, 2015 at 3:28 sheriffderek asked Jun 14, 2015 at 19:09 sheriffdereksheriffderek 9,0536 gold badges45 silver badges70 bronze badges 2
  • One approach to do this is to have the blank space in your icon file. – Saeed Hamed Commented Jun 14, 2015 at 19:15
  • 1 @SaeedHamed - That is an approach... but given that I only have a square to work with, and the logo is already wider than it is tall... it would have to bee smaller... and - this is all about being a perfectionist... and more about the concept and general understanding of the browser tab limitations - than just making it work on this one site. I want the favicon as big as possible. – sheriffderek Commented Jun 14, 2015 at 19:58
Add a ment  | 

2 Answers 2

Reset to default 11

Looks like browsers trim leading white space characters, but the unicode 205f medium mathematical space character seems to work:

document.title = '​​\u205f​​​ Takedown';

Probably the option according to me would be to use  .

本文标签: javascriptAdd a space to the browsertab titleStack Overflow