Monday, September 08, 2008

Animating favicon the hard way

You can animate your page's favicon by using an animated gif instead of an ico file, but you can also do it by rotating the href value in the <link> tag.

Unfortunately, you have jump thru a few hoops. Just changing your link's href tag won't do anything:

$("link").get(0).href = "newicon.ico";

You also have to remove the <link> tag from the dom and re-add it:

function setFavIcon( src )
var link = $('link').get(0);
var linkparent = link.parentNode;
link.href = src;