Reputation: 18285
How can you remove the favicon using Javascript in google chrome? The goal is to return it to the browser default, which is in this case a blank image.
I found this question, but it doesn't work if you leave the link.href
attribute as empty.
Even if the favicon is set because there is a favicon.ico file on the server, I'd like to remove it and set it back to the default.
This only needs to work in chrome.
Thanks!
Upvotes: 9
Views: 6432
Reputation: 3193
As a combination of @MatthewFlachen's answer and what I found here: Dynamically generated favicon, one can dynamically generate a blank data url using the canvas API.
link.href = document.createElement("canvas").toDataURL("image/x-icon");
Upvotes: 1
Reputation: 7706
Putting those comments into answer form:
Suggestions:
chrome-resource://favicon/
or chrome://favicon/
I'm a bit surprised the AJAX solution worked for you because, I'm on Chrome 4.1.249.1064 (45376) and it doesn't work for me.
EDIT: It doesn't seem like you'll need much from the AJAX solution. It seems that favicon.js
is all you really need. All it seems to do is what the JavaScript solution you mentioned plus a little more handling (ie remove existing favicon). Their "dynamic" part is just a document.onkeypress
.
EDIT: Additional reference:
Upvotes: 2
Reputation: 284786
Have you tried using an empty transparent image?
Try:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAAZiS0dEAP8A/wD/oL2nkwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9oFFAADATTAuQQAAAAZdEVYdENvbW1lbnQAQ3JlYXRlZCB3aXRoIEdJTVBXgQ4XAAAAEklEQVQ4y2NgGAWjYBSMAggAAAQQAAGFP6pyAAAAAElFTkSuQmCC
Upvotes: 4