gpt-3.5-turbo-0125· openai
from WildChat-4.8M
Can you write me a little javascript script that I can add anywhere in my code that will…
- User
Can you write me a little javascript script that I can add anywhere in my code that will change the favicon of the page to a certain link?
- Assistant
Sure! Here is a simple JavaScript script that you can add to your code to change the favicon of the page to a certain link:
javascriptfunction changeFavicon(link) { var linkTag = document.querySelector("link[rel*='icon']") || document.createElement('link'); linkTag.type = 'image/x-icon'; linkTag.rel = 'shortcut icon'; linkTag.href = link; document.getElementsByTagName('head')[0].appendChild(linkTag); } // Call the function with the link to the new favicon changeFavicon('https://example.com/favicon.ico');You can add this script anywhere in your code, and make sure to replace
'https://example.com/favicon.ico'with the link to the desired favicon.