Skip to content

Instantly share code, notes, and snippets.

@yblee85
Created September 23, 2015 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yblee85/b53b19b7fa57fe2f42df to your computer and use it in GitHub Desktop.
Save yblee85/b53b19b7fa57fe2f42df to your computer and use it in GitHub Desktop.
update favicon dynamically
function updateFavicon(faviconURL) {
var src = faviconURL;
var head_node = document.head || document.getElementsByTagName('head')[0];
var link = document.createElement('link'),
oldLink = document.getElementById('favicon');
link.id = 'favicon';
link.rel = 'shortcut icon';
link.href = src;
if (oldLink) {
head_node.removeChild(oldLink);
}
head_node.appendChild(link);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment