Dynamic Flash generated favicon

// February 27th, 2009 // Experiments, Source code & tutorials

Via Bnox I saw that you can change your favicon dynamically. After some research I found out that the magic trick lays in 3 lines of javascript:

(fi = the path to the favicon )

function setFavIcon(fi)
{
	var	icon=document.getElementById('favicon');
	(newIcon = icon.cloneNode(true)).setAttribute('href',fi);
	icon.parentNode.replaceChild(newIcon,icon);
}

Sadly, it only seems to work in FireFox and Opera. If you have a solution for this problem, please leave a comment.

Since Flash easily can generate png’s and talk to Javascript, that called for a little experiment:
You can draw your own favicon for this site on the canvas below. It updates automatically.

Share:

Post on Twitter
Share on Facebook
Bookmark this on Delicious
Share on LinkedIn
Stumble Now!
Digg This
Reddit This
Vote on DZone

3 Responses to “Dynamic Flash generated favicon”

  1. eric says:

    Ya lo he visto ^^

  2. Kris says:

    Sorry Eric, my Spanish isn’t that good. what do you mean?

  3. luuk says:

    hehe echt te bizar
    ik kan er echt totaal geen functie voor verzinnen, maar toch leuk :P

Leave a Reply