为什么我的 Edge 图标不起作用,而它在 Chrome 上起作用?

Why does my Edge favicon not work whereas the it does on Chrome?

我在本地 Windows PC 上有一个 html 运行ning 的简单块

<html>
<head>
    <title>FavIcon Test</title>
    <link id='favicon' rel='icon' href='favicon.ico' type='image/x-icon'/>
</head>
<body style='margin-left:10px'>
    Hello World
</body>
</html>

我抓取了一个随机的网站图标文件*并将其保存到与 html 相同的位置,并在 Chrome 和 Edge 中 运行 它; Chrome 向我显示了预期的站点图标,而 Edge 未能显示它。

这是怎么回事?

谢谢 安倍

*例如转到 https://ico.org.uk/favicon.ico 然后右键单击结果 [将图像另存为...]

由于从服务器返回的 不完整 headers 和 Edge 无法访问本地主机,因此该图标不会显示在本地服务器的 Edge Legacy 上一些 Windows 安全设置 。详细信息请参考this answer.

如果您将站点部署到 Web 服务器或使用绝对全局 http-address 网站图标 href,该问题将得到解决。以下代码将适用于 Edge Legacy:

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>FavIcon Test</title>
    <link id='favicon' rel='icon' href='https://ico.org.uk/favicon.ico' type='image/x-icon' />
</head>
<body style='margin-left:10px'>
    Hello World
</body>
</html>