jQuery \"add to bookmarks\"


/ Published in: jQuery
Save to your folder(s)

works in all the major browsers that support adding to bookmarks, FF, IE, Opera. Safari and Chrome dont support this, so for them, a nice message :)


Copy this code and paste it in your HTML
  1. $("a#bookmark").click(function(){
  2. var bookmarkUrl = this.href;
  3. var bookmarkTitle = this.title;
  4.  
  5. if ($.browser.mozilla) // For Mozilla Firefox Bookmark
  6. {
  7. window.sidebar.addPanel(bookmarkTitle, bookmarkUrl,"");
  8. }
  9. else if($.browser.msie || $.browser.webkit) // For IE Favorite
  10. {
  11. window.external.AddFavorite( bookmarkUrl, bookmarkTitle);
  12. }
  13. else if($.browser.opera ) // For Opera Browsers
  14. {
  15. $(this).attr("href",bookmarkUrl);
  16. $(this).attr("title",bookmarkTitle);
  17. $(this).attr("rel","sidebar");
  18. $(this).click();
  19. }
  20. else // for other browsers which does not support
  21. {
  22. alert('Please hold CTRL+D and click the link to bookmark it in your browser.');
  23. }
  24. return false;
  25. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.