Html 浏览器不显示 favicon.ico,但它存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19104795/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 13:59:21  来源:igfitidea点击:

Browser doesn't show favicon.ico, but it exists

htmlwebfavicon

提问by 124bit

My site is http://belhimplast.by/en/I made a favicon for it. In the headI have:

我的网站是http://belhiplast.by/en/我为它制作了一个图标。在head我有:

 <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">

I can see the favicon.icousing the URL http://belhimplast.by/favicon.ico

我可以使用 URL http://belhiplast.by/favicon.ico查看favicon.ico

But any browser doesn't show it. Help, please.

但是任何浏览器都不会显示它。请帮忙。

采纳答案by Guffa

I see it used as icon when I browse to your page.

当我浏览到您的页面时,我看到它用作图标。

If you have visited your page before (duh!) it's likely because the browsers remember that there wasn't any icon there before, and don't update it right away. Browsers remember the icons for different sites, so that they don't have to request it every time that the site name is shown (for example in the bookmarks or the history).

如果您之前访问过您的页面(呃!),很可能是因为浏览器记住了之前没有任何图标,并且不会立即更新它。浏览器会记住不同站点的图标,因此它们不必在每次显示站点名称时(例如在书签或历史记录中)请求它。

Also, it's not guaranteed that every user sees the favicon, some browsers simply doesn't display some icons sometimes, for no apparent reason.

此外,不能保证每个用户都能看到 favicon,某些浏览器有时会无缘无故地不显示某些图标。

回答by Po Rith

Browser will load from cached data. Try updating your call to force an update via. new file-name.

浏览器将从缓存数据加载。尝试更新您的电话以强制更新。新文件名。

<link rel="shortcut icon" href="/favicon.ico?v=2" type="image/x-icon">

回答by Kirill Novik

Takeaway from the Rest of the Similar Posts

其他类似帖子的总结

It is Important to Close ALLthe Windows for the Browser You Are Testing against and Start It Fresh to See the Change Happen. (Doesn't Work on Edge)

关闭您正在测试的浏览器的所有Windows 并重新启动它以查看更改的发生非常重要。(在 Edge 上不起作用)

Aside Notes

旁注

I have stumbled upon this issue myself. After researching other answers, there are many suggestions to fix it.

我自己偶然发现了这个问题。在研究了其他答案之后,有很多建议可以解决它。

Some people can't rid of the old icon: How to clear the icon cache of Chromium browser

有些人无法摆脱旧图标:如何清除Chromium浏览器的图标缓存

Others wanted to force refresh: How do I force a favicon refresh

其他人想要强制刷新:我如何强制刷新网站 图标

回答by Antonio

I had the same problem. This is my favicon tag:

我有同样的问题。这是我的图标标签:

<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico"/>

Don't forget close it.

不要忘记关闭它。

I cleaned browser cache, but it didn't fixed a problem.

我清理了浏览器缓存,但没有解决问题。

I saw my favicon just after Chrome and Firefox restart. In my opinion, it's a strange hard browser caching

在 Chrome 和 Firefox 重新启动后,我看到了我的网站图标。在我看来,这是一个奇怪的硬浏览器缓存

回答by Rogi

try to use only rel="icon" in your rel... no rel="shortcut icon"

尝试在您的 rel 中仅使用 rel="icon" ... 没有 rel="shortcut icon"

回答by Rob

CTRL+F5can help in some cases as it will force-reload all elements on the page. Closing and opening a tab doesn't always help.

CTRL+F5在某些情况下会有所帮助,因为它会强制重新加载页面上的所有元素。关闭和打开选项卡并不总是有帮助。

回答by droduit

I had the same problem :

我有同样的问题 :

the favicon exists(you can access it by its url), but doesn't show up, wether I am in local (with WAMP) or on a real webserver.

收藏夹图标存在(您可以通过其 url 访问它),但不显示,无论我是在本地(使用 WAMP)还是在真实的网络服务器上。

I had the following code :

我有以下代码:

<link rel="icon" sizes="192x192" href="https://example.com/public/images/favicon/favicon.png" type="image/png">

The problem was that I had made some echoand var_dumpof PHP variables before the <!DOCTYPE html>was displayed.

问题是,我已经做了一些echovar_dumpPHP变量之前<!DOCTYPE html>被显示。

Once I had removed all the echoand var_dump, the favicon immediately worked on both local and web server.

一旦我删除了所有echovar_dump,图标立即在本地和网络服务器上工作。

回答by kokabi

Before doing anything, check your website in the browserling. If the favicon displayed there, you don't need to do anything further. At that moment, your browser decided to go crazy!

在做任何事情之前,请在浏览器中检查您的网站。如果网站图标显示在那里,则您无需进一步执行任何操作。那一刻,您的浏览器决定发疯!