How to prevent the browser from asking for the favicon?

我的未来我决定 提交于 2019-12-03 16:19:07

问题


Is there some directive I could use in my HTML to tell the browser not to ask for the favicon?


回答1:


No, I don't think there is. From Wikipedia:

Most web browsers do not require any HTML to retrieve a favicon that conforms to the de facto file name and type (favicon.ico) located in the web site's root. If no favicon link is detected upon HTML page load completion and no previous site visits are recorded in the browser's history, a favicon.ico is requested automatically.[8]

The only thing you could do is explicitly point the browser to a different location (that for example could return a 204 no content)

<link rel="shortcut icon" href="http://www.example.com/my_empty_resource" />



回答2:


You could try pointing the <link> at a data URL. As commented below, IE will not like this, though.

Example (from 11011.net): <link rel="icon" type="image/gif" href="data:image/gif;base64,R0lGODlhEAAQAIAAAAAAAAAAACH5BAkAAAEALAAAAAAQABAAAAIgjI+py+0PEQiT1lkNpppnz4HfdoEH2W1nCJRfBMfyfBQAOw==" />

Edited to reflect Pekka's concern regarding IE.



来源:https://stackoverflow.com/questions/4867206/how-to-prevent-the-browser-from-asking-for-the-favicon

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!