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>:

<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#-->

Result

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:
ONCLICK="this.setHomePage('http://www.myhome.com')"
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 psacake.com
Version 7.21 | Advertise on this site