Html favicon.ico 没有出现在任何地方

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28909614/
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 03:38:03  来源:igfitidea点击:

favicon.ico not showing up anywhere

htmlbrowserfavicon

提问by ProfRose

I've looked at several posts on here, and I've done further research online, but I can't see to find the problem.

我看了这里的几篇文章,并在网上做了进一步的研究,但我看不到问题所在。

I put the favicon.ico in the main directory, but it's not showing up on any browser. I've tried it personally on Firefox and Safari, and I've tried the rest on Browsershots.

我将 favicon.ico 放在主目录中,但它没有显示在任何浏览器上。我在 Firefox 和 Safari 上亲自尝试过,其余的我都在 Browsershots 上尝试过。

I also have this line in the head of the html:

我在 html 的头部也有这一行:

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

I've also tried it without the type..., as I have it on other pages on the same server.

我也试过没有类型...,因为我在同一台服务器的其他页面上有它。

This website doesn't show its favicon (thistle)

该网站不显示其网站图标(蓟)

This website does show its favicon (greenman)

这个网站确实显示了它的 favicon (greenman)

Two of my sites on the same server with the favicon in the same place of the site's directory. ??

我的两个站点在同一台服务器上,网站图标位于站点目录的同一位置。??

The only thing I can figure is there was a problem converting the ico online and saving it on my MacBook Pro before uploading it to the server?

我唯一能想到的是在线转换 ico 并将其保存在我的 MacBook Pro 上,然后再将其上传到服务器时出现问题?

Any help or hints or thoughts are greatly appreciated.

非常感谢任何帮助或提示或想法。

回答by Jonathan McLaren

Had the same problem. Found this great answer: https://stackoverflow.com/a/16375622/5359989

有同样的问题。找到了这个很好的答案:https: //stackoverflow.com/a/16375622/5359989

What worked for me was changing 'favicon.ico' to something unique such as 'myfavicon.ico' and referencing it in the html accordingly. Hope this works for you also.

对我有用的是将“favicon.ico”更改为诸如“myfavicon.ico”之类的独特内容,并相应地在 html 中引用它。希望这也适用于您。

回答by AndrewL64

Change this:

改变这个:

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

To this:

对此:

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

Another reason why your favicon is not shown could be because you're viewing a cached version of your site.

未显示您的收藏夹图标的另一个原因可能是因为您正在查看网站的缓存版本。

Clear your cache and open the site again and you will see the favicon.

清除缓存并再次打开站点,您将看到网站图标。

回答by Dai

You're using a relative path in your href=""attribute. Change it to a root-relative path /favicon.icoor an absolute path http://yoursite.com/favicon.ico.

您在href=""属性中使用了相对路径。将其更改为根相对路径/favicon.ico或绝对路径http://yoursite.com/favicon.ico

回答by patrick

Chrome didn't like the fact my favicon.ico was a 64x64 image. I changed it to a 32x32 pixel image and it showed right up!

Chrome 不喜欢我的 favicon.ico 是 64x64 图像这一事实。我把它改成 32x32 像素的图像,它就显示出来了!

回答by user876725

Not all icons are the same! I had this problem for a while and could never figure out why some browsers didnt show the icon. I knew with absolute certainty that the file existed where the link tag said it did. Eventually I discovered that, at least for Chrome and Opera, they WONT display some icons depending on the formats within the .ico file.

并非所有图标都相同!我遇到这个问题有一段时间了,一直想不通为什么有些浏览器没有显示图标。我绝对确定该文件存在于链接标签所说的位置。最终我发现,至少对于 Chrome 和 Opera,它们不会根据 .ico 文件中的格式显示一些图标。

E.g. a .ico that has, only, 64x64 and 32x32 and 16x16 formats will display.

例如,将显示只有 64x64 和 32x32 和 16x16 格式的 .ico。

BUT a .ico that also has, IN ADDITION TO those above, 512x512 256x256, 128x128 and 48x48 formats, will NOT display.

但是,除了上述格式之外,还具有 512x512 256x256、128x128 和 48x48 格式的 .ico 将不会显示。

That really looks like a browser issue but its curious that it affects more than one browser.

这确实看起来像是浏览器问题,但奇怪的是它会影响多个浏览器。

Anyhow the solution, for me at least, was to only include 64x64 and 32x32 and 16x16 formats.

无论如何,至少对我来说,解决方案是只包含 64x64、32x32 和 16x16 格式。