Community Central
Register
Community Central
Forums: Index Support Requests Dynamic favicon javascript
Fandom's forums are a place for the community to help other members.
To contact staff directly or to report bugs, please use Special:Contact.
Archive
Note: This topic has been unedited for 4367 days. It is considered archived - the discussion is over. Information in this thread may be out of date. Do not add to unless it really needs a response.


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 · 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 · contr) 12 Apr 2012 4:41 PM Pacific
Are we allowed to make random favicons? With this code combined with the random wordmark code, then it seems like a random favicon is possible... (for everyone, not just one user) 70.24.248.211 06:09, April 13, 2012 (UTC)