Rails代码(HAML):
= favicon_link_tag 'favicon.ico'
favicon.ico
位于
app/assets/images/favicon.ico
它在本地和远程(在生产中)都可以在Firefox中工作,但对于本地和远程Chrome都不显示图像
在任一浏览器中查看生产源将显示:
<readyhead>
...
<link href="/assets/favicon-2d05a112081aa8cc9c3caa576862077d.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" />
...
</readyhead>
在任一浏览器中查看开发源代码都会显示:
<readyhead>
...
<link href="/assets/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" />
...
</readyhead>
我没有IE,但你可以在http://www.railslinks.com上看到它(我很好奇!)
发布于 2014-06-14 23:50:58
如果你用chrome dev工具检查你的页面源代码,你可以看到Chrome是如何解析你的HTML的:
<html>
<head>
<style type="text/css">
</style>
</head>
<body>
<readyhead>
<!-- some more stuff ... -->
<link href="/assets/favicon-2d05a112081aa8cc9c3caa576862077d.ico" rel="shortcut icon" type="image/vnd.microsoft.icon">
</readyhead>
<!-- some more stuff ... -->
</body>
</html>
问题是<readyhead>
不是一个有效的超文本标记语言元素,所以Chrome创建了一个单独的<head>
元素作为替代,并假设<readyhead>
属于<body>
标记。
要解决这个问题,你必须将<readyhead>
重命名为<head>
,然后Chrome才能正确地解析你的HTML。不管怎样,这个元素应该是什么?这是无效的HTML。
https://stackoverflow.com/questions/24221181
复制相似问题