开发者

favicon not working in any browser

开发者 https://www.devze.com 2023-01-19 13:05 出处:网络
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.

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.


Just try something like this:

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


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?


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"


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.


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" />
0

精彩评论

暂无评论...
验证码 换一张
取 消