Saturday, December 31, 2005

Add to Favorites (IE) / Bookmark (Firefox) Javascript

Most web browsers like Firefox (Ctrl+D), Opera (Ctrl+T) and IE (Ctrl+D) provide keyboard shortcuts to enable users bookmark their favorite pages.

But not every visitor is a power user, so for them, you can add a quick “Bookmark this page” link in all your pages. Clicking on the link prompts the user with a dialog box to add the specified URL to the Favorites list.

The javascript code mentioned on IE MSDN page doesn’t work in other browsers.
window.external.AddFavorite(location.href, document.title);

The following modified version of “Add to Favorites” javascript code works across IE, Mozilla Firefox and Opera Browsers. Template Tags for Blogger, Movable Type and Wordpress platform are commented.
If your audience are visiting the site from a different web browser or if javascript is not supported , the bookmark link is not displayed.

No comments:

Post a Comment