Kedar's Tech Blog

Wednesday, September 03, 2003

How to Add a Shortcut Icon to a Web Page?

Creating a Shortcut Icon for a Web Page

The required size of a shortcut icon is 16x16 pixels. Use the following HTML code to enable this:

<HEAD>
<LINK REL="SHORTCUT ICON" HREF="http://www.mydomain.com/myicon.ico">
</HEAD>

The only way a shortcut icon appears on a user's Favorites menu and Address bar is if the user chooses to add your page as a favorite.

This is how you can add a button or a link that prompts user to add your page to favorites. Use the following Javascript code:

<SCRIPT>
<!--
if ((navigator.appVersion.indexOf("MSIE") > 0)
&& (parseInt(navigator.appVersion) >= 4)) {
var sText = "<u><span style='color:blue;cursor:hand;'";
sText += "onclick='window.external.AddFavorite(location.href,";
sText += "document.title);'>Add this page to your favorites</span></u>";
document.write(sText);
}
//-->
</SCRIPT>