How to Change Favicon with JavaScript

This code comes in handy when you don’t have access to the head of the page and need to change the favicon.

(function() {
var link = document.querySelector(“link[rel*=’icon’]”) || document.createElement(‘link’);
link.type = ‘image/x-icon’;
link.rel = ‘shortcut icon’;
link.href = ‘https://yourdomain.com/favicon.ico’;
document.getElementsByTagName(‘head’)[0].appendChild(link);
})();

The post How to Change Favicon with JavaScript appeared first on Bootstrap Creative.

Generated by Feedzy