The following example takes advantage of an intrinsic DHTML behavior to change the user's home page to the current page. The style block, which goes in the <HEAD> of the document, associates the .homepage class with the built-in behavior. The inline STYLE on the <SPAN> tag simulates the look and feel of a hot link, but clicking the link doesn't cause a new page to be loaded.
This example also uses conditional comments, a new Internet Explorer 5 feature, to gracefully hide the link from downlevel browsers.
The style block goes in the page <HEAD>:
<STYLE>
<!--
.homepage {behavior:url(#_IE_)}
-->
</STYLE>
This code can be placed anywhere in the page body:
<!--#if IE 5#> <U><SPAN STYLE='color:blue;cursor:hand;' CLASS=homepage ONCLICK='this. setHomePage(window.location);'> Make this your home page</SPAN></U> <!#endif#-->
You can also change the user's home page to a page other than the current page by replacing window.location in the above example with a specific URL.
For example,
ONCLICK="this.setHomePage('http://www.myhome.com')"
To prevent "slamming," Internet Explorer first asks the user if he or she wants to change their home page rather than setting it automatically.