Create Add to Favorites/Bookmark button in Javascript

Most today's web browsers like Firefox (Ctrl+D), Opera (Ctrl+T) and IE (Ctrl+D) provide a keyboard shortcuts to enable users bookmark their favorite pages. But if you want to provide your visitors with a "Bookmark this page" link they can click you may use the code below: It works in IE, FireFox and Opera. Clicking on the link prompts the user with a dialog box to add the specified URL to the Favorites list.

[View All Snippets]
Show Plain Text »
  1. <script type="text/javascript">
  2. function CreateBookmarkLink(){
  3.     var title = document.title;
  4.     var url = window.location.href;
  6.     if(window.sidebar && window.sidebar.addPanel){
  7.         /* Mozilla Firefox Bookmark - works with opening in a side panel only */
  8.         window.sidebar.addPanel(title, url, "");
  9.     }else if(window.opera && window.print) {
  10.         /* Opera Hotlist */
  11.         alert("Press Control + D to bookmark");
  12.         return true;
  13.     }else if(window.external){
  14.         /* IE Favorite */
  15.         try{
  16.             window.external.AddFavorite(url, title);
  17.         }catch(e){
  18.                         alert("Press Control + D to bookmark");
  19.                 }            
  20.     }else{
  21.         /* Other */
  22.         alert("Press Control + D to bookmark");
  23.     }
  24. }
  25. </script>
  27. <a href="javascript:CreateBookmarkLink();">Add to Favorites/Bookmark</a>
Create Your Free Account
Please remember that this information is essential to use our services correctly.
After creating the account you will be able to download all of our FREE products.
Fields marked with * are mandatory

Please send me information about updates, new products, specials and discounts from ApPHP!
We recommend that your password should be at least 6 characters long and should be different from your username/email. Please use only letters of the English alphabet to enter your name.

Your e-mail address must be valid. We use e-mail for communication purposes (order notifications, etc). Therefore, it is essential to provide a valid e-mail address to be able to use our services correctly.

All your private data is confidential. We will never sell, exchange or market it in any way. Please refer to Privacy Policy.

By clicking "Create Account", you are indicating that you have read and agree to the ApPHP Terms & Conditions.

Quick Registration with: Facebook / Google