8

GMAIL in chrome has a favicon that shows an unread message count. Does anyone know how they do that? Is that them changing images? Or is there a property that allows you to set the number near the favicon?

Thanks

AnApprentice
  • 103,298
  • 185
  • 610
  • 989
  • This is not how gmail does it, but this is how I was able to mock it: http://stackoverflow.com/questions/6964144/dynamically-generated-favicon/6964230#6964230 – Joe Sep 09 '11 at 23:45

5 Answers5

7

I am not 100% certain on how Google accomplishes this however, someone created a UserScript to mimic the functionality. You can view the source code of this script and see how they accomplished it.

http://userscripts.org/scripts/review/39432

EDIT

I'm including this resource since userscripts is no longer around:

http://lab.ejci.net/favico.js/

on github

https://github.com/ejci/favico.js

jon3laze
  • 3,118
  • 6
  • 33
  • 66
  • 1
    This is the answer for How does GMAIL have a favicon that shows an unread message count? – coto Jan 28 '14 at 07:28
1

There's no property that sets a number next to the favicon, but you can change it in javascript. Check out this question Changing website favicon dynamically

Community
  • 1
  • 1
spike
  • 9,514
  • 8
  • 50
  • 82
0

I don't know how Google did it, but the way I did it way:

 $('body').append($('<link rel="icon" type="image/ico" href="http://localhost/myfavicon.ico"/>'))

As needed.

Michael Lorton
  • 41,023
  • 26
  • 92
  • 136
-1

I have no clue how they do it, but there's no reason you can't have your /faveicon.ico be responded to by a dynamic server-side script which generates/provides certain content based on information of the user in question.

That said... I don't think most browsers would get the updated Faveicon usually, as most seem to only check it once per session.

Andrew Barber
  • 38,454
  • 20
  • 92
  • 120