Created
November 2, 2019 16:42
-
-
Save avilde/66beb017ce5a5da9afca85dfdd80ec76 to your computer and use it in GitHub Desktop.
Replace favorite icon for your web page in real time.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const setOrReplaceFavoritesIcon = (icon: string = defaultFavIcon) => { | |
const link: HTMLLinkElement = | |
document.querySelector('link[rel*="icon"]') || | |
document.createElement('link'); | |
link.type = 'image/x-icon'; | |
link.rel = 'shortcut icon'; | |
link.href = icon; | |
document.getElementsByTagName('head')[0].appendChild(link); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment