Click here to Skip to main content
15,896,450 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Guys,

I having a requirement of not displaying the favicon on few pages. So, to do that
I have mentioned the href attribute of link tag to blank (href="") to make favicon disappear. But unfortunately this is not working as I expected and it still displays the favicon which is placed under root folder.

Can any one help or provide your valuable suggestions on this. I want to display a defalut favicon/blank favicon on the pages on which I dont want to show my actual favicon.



Thanks
Yashwanth
Posted

1 solution

Hi,

You must have set the favicon on your master page like this:
XML
<link id="favicon" rel="shortcut icon" type="image/png" href="favicon.png" />


You should be able to just pass the name of the icon you want along in the view data and throw it into the head tag. You can change the favicon for the respective page using Javascript by changing the HREF element on this link, for instance (assuming you're using JQuery):
JavaScript
$("#favicon").attr("href","favicon2.png");


Another way here could be, you can add favicon like this:
XML
<link runat="server" rel="shortcut icon" href="" type="image/x-icon" />
<link runat="server" rel="icon" href="" type="image/ico" />


And in .aspx.cs :
C#
protected void Page_Load(object sender, EventArgs e)
{
    Link1.Attributes.Add("href", "favicon.ico");
    Link1.Attributes.Add("href", "favicon.ico");
}


Check this out:

http://thelazybubble.blogspot.in/2011/08/add-dynamic-fevicon-to-your-websites-in.html[^]

Hope this helps !! :) :)

Regards,
Praneet
 
Share this answer
 
Comments
YashwanthBathini 28-Oct-14 7:49am    
Hi Praneet,

Thank you very much for your response. I have tried the below 2 lines of code. (working on JSP)

<link rel="shortcut icon" href="" type="image/x-icon" />
<link rel="icon" href="" type="image/ico" />

But the issue remains the same i.e I can still see the icon instead of blank. This works in Firefox awesome but the issue is with Chrome and IE.
I think the reason behind this would be the browser's cache as it still refers to the old favicon instead of href="". And one more thing based on my analysis is the browser refers to the favicon from its history in case if the url it is pointing to is invalid or to an unmodified image.

Do you have any idea on how to resolve this caching issue.


Thanks
Yashwanth

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900