By Søren Madsen

Illustration that shows a list of bookmarks with associated iconsFavicons are those nice little icons that appear in your bookmarks, or in your browsers address bar, when you visit a website that has a favicon associated with it. It is website owners own little branding space, and they offer improved usability when you ie. are reviewing a long list of bookmarks, trying to find that particular website. This article shows how to extend the uses of the favicon, by allowing website visitors to leave their "brand" behind.

Quick and dirty - here's the code

Here's a nice little ASP function I wrote with help from David S. I use this in my comment system. When someone writes a comment and gives his websites URL, it checks whether the website in question has a favicon.ico or not - and if it has, the favicon is displayed next to the users name …

<% 	
Function HttpExists(uri)
Dim srvXmlHttp
Set srvXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
srvXmlHttp.setTimeouts 500, 500, 500, 500
srvXmlHttp.open "HEAD", uri, false
on error resume next

srvXmlHttp.send
If Err.Number = 0 Then
	If srvXmlHttp.Status=200 Then
	HttpExists=True
	else
	HttpExists=False
	end if
	else
	HttpExists=False
end if
End Function
'  ********************
' Now feed the function with an URL, like:
' domain = cmd("url")
domain = "http://www.picment.com"

 ' Make sure there is a trailing slash
If Right(domain, 1) <> "/" Then
domain = domain & "/"
End If

url2chk = domain & "favicon.ico"

If HttpExists(url2chk) then
Response.Write "<img src=""" & url2chk & """ alt=""Icon"" /> "
' else 
' Response.Write url2chk & " could not be found"
end if
%>

Obviously, this assumes that the favicon is actually named favicon, and that it is located at the root of the website you're "pinging". Nobody says it should - you could name it whatever you like, and place it where ever you like, but common practise for the last few years has been to place the favicon at the root, and naming it favicon.ico. The reason for this, is that a certain browser from version 5.x, automatically assumed that the the icon was named favicon, and was located at the root of the website - and if website owners wanted their icon to appear in said browsers bookmarks lists, they were forced to follow that convention. Whether this is good or bad, is definately arguable - but this is what we're taking advantage of in this article.

Try it out here :

Additional information

At the following links, you can find additional information for your favicon needs:

Why 'robots.txt and 'favicon.ico' are bad ideas and shouldn't be emulated
How To Create A Favicon
Movable Type Favicon plugin
In the comments to this article, 'OCB' wrote how to do something simular with PHP. Very nice.