Super-simple tool for dynamically setting the favicon image on a page.
Super simple util for setting the favicon of a page:
setFaviconfunction to the
Step 1. include it:
Step 2. Set your favicon like so:
windowsetFavicon'/new-url.png'; // should be 16x16 image (pngs are best)
If you're using this on the client but your project is in node.js you can install this with: https://github.com/henrikjoreteg/clientmodules and npm:
npm install favicon-setter
Then just do this:
var setFavicon = require'favicon-setter';setFavicon'/new-url.png';
If you've got jquery on the page, insert this after including jQuery.
Just one other little trick. If the original favicon was set by using a
<link rel="shortcut icon"> tag then you can restore the original after setting it by calling
setFavicon() without any arguments.
If you like this, follow @HenrikJoreteg on the twitterwebz.