Dynamic Drive DHTML code library!

spacer.gif (807 bytes)


Search DD
Recommend DD
Help Forums New
DHTML books

Featured Script
Rollover buttons 

Turn regular form buttons into rollover menus with this script!


Free JavaScripts

Link to DD

Do you use scripts from Dynamic Drive? Please give something back by linking to us...
spacer.gif (807 bytes)

Home Small4.gif (1046 bytes) Other Small4.gif (1046 bytes) Here

Add-to-Favorites Script IE

Contributor name: David Gardner
Homepage: N/A

Description: If you've been looking all over the web for a script that allows your surfers to easily add your site to their bookmark (favorites) list in IE, well, your search is over. The below script creates a link that, when clicked on, adds the specified page to the surfer's bookmark list.

Demo: (You can use either an image link or a regular text link)

Click here to instantly bookmark Dynamic Drive!

Directions: Developer's View

Step 1: Add the below code to the <head> section of your page:

Step 2: Create either an image or text link that will be used as the add-to-favorites link. For the href attribute, use the following code:


Here's an example:

<a href="javascript:addbookmark()">Bookmark this site!</a>

Since this script only functions in IE 4+, you may wish to hide it from other browsers by dynamically writing out the link. The easiest way to do that is to first use the document.all object to sniff out IE 4 users, then use the document.write() method to write out the link only for them. For example:

//if the user is using IE 4+
if (document.all)
document.write('<a href="javascript:addbookmark()">Bookmark this site!</a>')

It's up to you, though, on how exactly you want to do it.

Recommend Us!
-If you like Dynamic Drive, please recommend us to a friend...

All- Script works with Netscape 4 AND Internet Explorer 4+
NS- Indicates script works with Netscape 4 (NOT NS 6 yet)
IE- Indicates script works with Internet Explorer 4 and above
NS6!- Temporary index set up on script category pages to indicate script works in NS6

Copyright 1998-2004 Dynamic Drive. Please read Terms Of Use here before using any of the scripts.
Partners: JavaScript Tutorials | JavaScript Reference