I am working on a website which changes its favicon depending on the user details logged in. A controller processes this request at the back-end and sends the appropriate fa
Using JavaScript to change the favicon in IE11:
HTML
JS
// Chrome allows you to simply tweak the HREF of the LINK tag.
// Firefox appears to require that you remove it and readd it.
function setFavicon(url)
{
removeFavicon();
var link=document.createElement('link');
link.type='image/x-icon';
link.rel='icon';
link.href=url;
document.getElementsByTagName('head')[0].appendChild(link);
if (window.console) console.log("Set FavIcon URL to " + getFavicon().href);
}
function removeFavicon()
{
var links=document.getElementsByTagName('link');
var head=document.getElementsByTagName('head')[0];
for(var i=0; i
Demo: http://www.enhanceie.com/test/favicon/dynamic.htm
NOTE: This works in Chrome, Firefox, IE11+. It doesn't work in IE10 or earlier, Opera 12.15, or Safari 6.0.5(mac). Combine this method with your favicon.ico?v=xxxx method for earlier browsers.