Jump to content

Change favicon and Titel in Browser at runtime


erich.wanker
 Share

Recommended Posts

Hello ..

 

is it possible to change the favicon and Title (Browser-Tab) at runtime?

 

... i want to change the icon and title of browserTab - depending on the menuepoint of my ungui-application ...

 

and is it possible to use a png?  

 

ThaX for suggestions :-)

Link to comment
Share on other sites

Hi 

 

http://mathiasbynens.be/demo/dynamic-favicons

... Works in Firefox, Opera, and Chrome. Fails in Safari and Internet Explorer

function changeFavicon(src) { var link = document.createElement('link'),
     oldLink = document.getElementById('dynamic-favicon');
 link.id = 'dynamic-favicon'; 
 link.rel = 'shortcut icon';
 link.href = src;
 if (oldLink) {
  document.head.removeChild(oldLink);
 }
 document.head.appendChild(link);
};

changeFavicon('http://www.google.com/favicon.ico');

Best regards

  • Upvote 1
Link to comment
Share on other sites

and is it possible to use a png?  

 

Try

var link = document.createElement('link');
        link.type = 'image/png';
        //link.type = 'image/ico';
        link.rel = 'icon';
        link.href = 'images/ok.png';
        //link.href = 'http://www.google.com/favicon.ico';
        document.getElementsByTagName('head')[0].appendChild(link);

Best regards

Link to comment
Share on other sites

  • 4 years later...
 Share

×
×
  • Create New...