网站图标在任何浏览器中都不起作用

发布于 2024-09-26 19:42:56 字数 408 浏览 7 评论 0原文

嘿,我正在尝试让网站图标出现在我的网页上。免责声明:我以前从未这样做过,但看起来确实很简单。

我在名为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

三人与歌 2024-10-03 19:42:56

尝试这样的事情:

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

Just try something like this:

<link rel="shorcut icon" href="imgs/favicon.ico" type="image/x-icon" />
客…行舟 2024-10-03 19:42:56

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?

提笔落墨 2024-10-03 19:42:56

您必须在 标记中添加 type="application/x-icon"

编辑:波浪号是什么?无需从当前文件夹启动任何内容

href="pics/REDIcon.ico"

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

href="pics/REDIcon.ico"
夏日落 2024-10-03 19:42:56

将 type="image/x-icon" 添加到该链接:

<link rel="Shortcut Icon" href="~/pics/REDIcon.ico" type="image/x-icon" / >

您可能还需要重写该 href - 不确定浏览器如何处理 tildas (~)。

然后重新启动浏览器 - 它们通常会积极缓存网站图标的存在或缺失。

编辑:我不知道 asp.net 框架如何工作 - 但请确保您的图像已部署到应用程序的工作目录。

Add type="image/x-icon" to that link:

<link rel="Shortcut Icon" href="~/pics/REDIcon.ico" type="image/x-icon" / >

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.

胡大本事 2024-10-03 19:42:56

1) 添加 type="image/x-icon" 属性

2) 删除 ~.网站图标应该位于网站的根目录中(我一直把它放在那里并且它可以工作)。某些浏览器可能会在预定位置查找网站图标。检查返回的标记以确保一切都有效。

3) 清除浏览器缓存。我发现图标可能需要一段时间才能开始出现。

这是我的其中一个页面的示例:

<link rel="shortcut icon" type="image/x-icon" href="http://www.mysite.com/favicon.ico" />

1) Add the type="image/x-icon" attribute

2) 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:

<link rel="shortcut icon" type="image/x-icon" href="http://www.mysite.com/favicon.ico" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文