跨源 .ico 图像
Google Chrome 似乎懒得显示 具有跨源 src 属性。 火狐确实如此。因此,对于 Firefox,需要使用适用于 .png 图像的 iframe。但事实证明,Firefox 不能很好地处理具有 .ico src 属性的 iframe:Firefox 似乎根本没有在 iframe 中创建适当的元素。
那么问题是:是否可以在 Firefox 中显示跨源 .ico 图像?
谢谢!
Google chrome doesn't seem to bother to display an <img> with cross origin src attribute.
Firefox does. So for Firefox one would need to use an iframe which works fine for .png images. But it turns out that Firefox doesn't handle well iframes with an .ico src attribute: Firefox simply doesn't seem to create the appropriate elements in the iframe.
So the question is: is it possible to display a cross origin .ico image in Firefox?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
的
src
默认没有跨源策略。这就是为什么您可以从几乎任何地方链接您的图像(几乎,因为您可以将主机设置为不允许热链接 - 也许这就是这里出现的内容 -)。无论如何,请尽量避免在
标记中使用 .ico,因为它不会像 @Pekka 所说的那样在每个浏览器中显示。无论如何,有些人会这样做,因为许多软件将 .ico 文件保存为 .png (有点像伪装),但这仍然是一个技巧......
iframe 技巧也不起作用。
总之,仅在需要时才使用 .ico,但如果您希望与每个浏览器都有良好的兼容性,请避免使用它。
<img>
'ssrc
doesn't have a cross origin policy by default. That's why you can link your images from almost everywhere (almost, because you can set your host not to allow hotlinking -maybe that's what appears here-).Anyway, please, try to avoid the use of .ico in a
<img>
tag because it won't be shown in every browser as @Pekka said. Some will anyway because many software save .ico file as .png (kinda like a camouflage) but it still a trick...The iframe trick won't work either.
In summary, use .ico only if you need to but avoid it if you want a nice compatibility with every browser.
这绝对是不正确的。您的问题可能与图像的来源无关,而与格式有关。 ICO 主要是一种 Windows 格式,无法跨浏览器可靠地显示。
维基百科浏览器对图像格式的比较根本没有列出 ICO。
that is definitely incorrect. Your problem probably doesn't have to do with the image's origin, but with the format. ICO is mainly a Windows format and will not be reliably displayed across browsers.
The Wikipedia browser comparison on image formats doesn't list ICO at all.