Set a users home page

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 to gracefully hide the link from downlevel browsers.

The style block goes in the page <HEAD>:

.homepage {behavior:url(#_IE_)}

This code can be placed anywhere in the page body:

<!--#if IE 5#>
<U><SPAN STYLE='color:blue;cursor:hand;' 
  CLASS=homepage ONCLICK='this.
Make this your home page</SPAN></U>


Make this your home page

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:
To prevent "slamming," the browser first asks the user if he or she wants to change their home page rather than setting it automatically.

HTML 4.0 home page homepage DHTML

Back To Top
© 1998 - 2024
Version 7.21 | Advertise on this site