Forum:Dynamic favicon javascript

Not sure if anyone cares about this, but I thought I'd share it because some people might want to know. I recently discovered how to dynamically replace a favicon using javascript after doing a few google searches and a little tinkering (I don't really know javascript very much). For example, if you don't like Wikia's new favicon, you can add the following code to Special:MyPage/wikia.js here on community central to revert it back to the iconic curly W. /* Dynamically replace favicon with the old curly W */ $(function {   var link = document.createElement('link');    link.type = 'image/x-icon';    link.rel = 'shortcut icon';    link.href = 'http://images3.wikia.nocookie.net/__cb20111116173360/central/images/archive/6/64/20120405205346%21Favicon.ico';    document.getElementsByTagName('head')[0].appendChild(link); }); /* END dynamically replace favicon with the old curly W */

Anyways, if anybody with javascript knowledge sees this, please comment which browsers this works for, consider adding functionality for other browsers, and maybe add this to http://www.dev.wikia.com. I can confirm that this works for me on Chrome on my laptop, but that's all I know at the moment. — Mathmagician 21:42, April 12, 2012 (UTC)


 * Works for me on FireFox 11 (Win7x64). I think you can do this in a JQuery one-liner, but I'll have to play with it. -- Fandyllic (talk &middot; contr) 12 Apr 2012 4:34 PM Pacific


 * This seems to work also:

 $(function {   $('link[rel="shortcut icon"]').attr('href','http://images3.wikia.nocookie.net/__cb20111116173360/central/images/archive/6/64/20120405205346%21Favicon.ico'); });
 * -- Fandyllic (talk &middot; contr) 12 Apr 2012 4:41 PM Pacific