网站图标在任何浏览器中都不起作用
嘿,我正在尝试让网站图标出现在我的网页上。免责声明:我以前从未这样做过,但看起来确实很简单。
我在名为 pics 的文件夹中有一个 ico 图像,它是我项目的一部分。我正在尝试在我的母版页中执行此操作。
<link rel="Shortcut Icon" href="~/pics/REDIcon.ico"/>
这是正确的,对吧?还有什么我应该检查的吗?
任何帮助将不胜感激。
编辑:
我的代码现在看起来像:
<link rel="Shortcut Icon" href="pics/REDIcon.ico" type="image/x-icon"/>
但这仍然无法正常工作。
Hey, I am trying to get a favicon to appear on my webpage. Disclaimer: I have never done this before, but it does seem rather simple.
I have a ico image in a folder called pics that is part of my project. I am trying to do this inside my master page.
<link rel="Shortcut Icon" href="~/pics/REDIcon.ico"/>
That is correct, right? Is there anything else I should check?
Any help would be appreciated.
EDIT:
my code now looks like:
<link rel="Shortcut Icon" href="pics/REDIcon.ico" type="image/x-icon"/>
This however is still not working properly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
尝试这样的事情:
Just try something like this:
asp.net 是否正确地将波形符 (~) 转换为可用于 HTML 的内容?如果这部分直接进入 html,而不在服务器上进行任何预处理,我怀疑浏览器将能够找到该图标,因为它们将很难解释该 href。如果您使用图标的绝对、相对或根相对路径,还会遇到此问题吗?
Is asp.net correctly converting the tilde (~) into something that works with HTML? If this part is going directly into the html, without any pre-processing on the server, I doubt browsers will be able to find the icon because they'll have a hard time interpreting the href. Do you still have this problem if you use an absolute, relative, or root-relative path to the icon?
您必须在
标记中添加
type="application/x-icon"
。编辑:波浪号是什么?无需从当前文件夹启动任何内容
You have to add
type="application/x-icon"
in the<link>
tag.EDIT : what's the tilde ? Nothing is necessary to start from current folder
将 type="image/x-icon" 添加到该链接:
您可能还需要重写该 href - 不确定浏览器如何处理 tildas (~)。
然后重新启动浏览器 - 它们通常会积极缓存网站图标的存在或缺失。
编辑:我不知道 asp.net 框架如何工作 - 但请确保您的图像已部署到应用程序的工作目录。
Add type="image/x-icon" to that link:
You may also need to rewrite that href - not sure how browsers handle tildas (~).
Then restart your browser - they often aggressively cache the presence, or lack of, a favicon.
Edit: I don't know how asp.net frameworks work - but make sure your image has been deployed to the working directory of your app.
1) 添加
type="image/x-icon"
属性2) 删除 ~.网站图标应该位于网站的根目录中(我一直把它放在那里并且它可以工作)。某些浏览器可能会在预定位置查找网站图标。检查返回的标记以确保一切都有效。
3) 清除浏览器缓存。我发现图标可能需要一段时间才能开始出现。
这是我的其中一个页面的示例:
1) Add the
type="image/x-icon"
attribute2) Remove the ~. The favicon should be in the root of the website(That's where I have always put it and it works). Some browsers may look in predetermined locations for the favicon. Check the returned markup to make sure everything is valid.
3) Clear the browser's cache. I have found that it may take awhile for the icon to start appearing.
Here's an example from one of my pages: