Resolved Conditional html FavIcon

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,530
Location
Lansing, MI; USA
Programming Experience
10+
I have an aspx page where I'm trying to set the FavIcon using the conditional html statements, here's what I have so far:
VB.NET:
<head runat="server">
    <!--[if gte IE 7]>
        <link rel="SHORTCUT ICON" href="/Images/jb32.ico"/>
    <![elseif lte IE 6]>
        <link rel="SHORTCUT ICON" href="/jb16.ico"/>
    <![else]>
        <link rel="icon" type="image/vnd.microsoft.icon" href="/Images/jb32.ico" />
    <![endif]-->
</head>
IE 7 & 8 support 32x32 icons, which is what jb32.ico is. IE 6 supports 16x16 icons, which is what jb16.ico is and older IE just picks up the icon file in the root directory and uses that, which is why jb16.ico is in the root, not the images folder.

The icon's showing in IE fine.

FF and other browsers use a different Link Rel call to set the icon, which is where the [else] comes in, but in FF 3.5 (and I can test this in FF 3.0.11 tomorrow) the icon doesn't show in the title bar when it's in the [else], however it does when it's outside of the conditional tag altogether, meaning this works fine in FF 3.5:
VB.NET:
<head runat="server">
    <link rel="icon" type="image/vnd.microsoft.icon" href="/Images/jb32.ico" />
</head>
Is there something I'm doing wrong? Anyone have any suggestions
 
HTML:

<head>

<link id="lnkFav" runat="server" />

</head>



Code behind:

Select case Request.Browser.Browser

Case "id":

Me.lnkFav.Attributes.Add("rel","SHORTCUT ICON")

Me.lnkFav.Attributes.Add("href","yourFavIco.ico")

Case "mozilla"

Me.lnkFav.Attributes.Add("rel","SHORTCUT ICON")

Me.lnkFav.Attributes.Add("href","yourFavIco.ico")

default

End select
 
Back
Top