Cross-browser bookmark / add to favorites JavaScript

Is there a cross-browser bookmark / add to favorites using JavaScript.

I was looking for a list, but no one is working. Can you offer any suggestions?

+56
javascript cross-browser bookmarks
Jun 11 '10 at 17:09
source share
4 answers

jQuery version

JavaScript (modified from a script I found someone on the site - I just can’t find the site again, so I can’t give the person credit):

$(document).ready(function() { $("#bookmarkme").click(function() { if (window.sidebar) { // Mozilla Firefox Bookmark window.sidebar.addPanel(location.href,document.title,""); } else if(window.external) { // IE Favorite window.external.AddFavorite(location.href,document.title); } else if(window.opera && window.print) { // Opera Hotlist this.title=document.title; return true; } }); }); 

HTML:

 <a id="bookmarkme" href="#" rel="sidebar" title="bookmark this page">Bookmark This Page</a> 

IE will show an error if you did not run it from the server (it does not allow JavaScript bookmarks via JavaScript when viewed as file://...

If you need a more complete script, you can always buy it from this page (No, I'm not connected to this site ... LOL).

+45
Jun 11 '10 at 17:26
source share

I do not think so. Bookmarks / favorites should be under the control of the user, imagine if any site you visited can only bookmark yourself with some javascript.

+8
Jun 11 '10 at 17:18
source share
 function bookmark(title, url) { if(document.all) { // ie window.external.AddFavorite(url, title); } else if(window.sidebar) { // firefox window.sidebar.addPanel(title, url, ""); } else if(window.opera && window.print) { // opera var elem = document.createElement('a'); elem.setAttribute('href',url); elem.setAttribute('title',title); elem.setAttribute('rel','sidebar'); elem.click(); // this.title=document.title; } } 

I used this and worked great in IE, FF, Netscape. Chrome, Opera and Safari do not support it!

+7
Aug 6 '11 at 9:25 a.m.
source share

How about using a solution like ShareThis or AddThis ? They have similar functionality, so it is quite possible that they have already solved the problem.

AddThis code has a huge version of for / else for the browser version for saving favorites, but in most branches ending with the user prompting to manually add the favorite, so I think that such a clean JavaScript implementation does not exist.

Otherwise, if you only need to support IE and Firefox, you have IE window.externalAddFavorite () and Mozilla window.sidebar.addPanel ().

+3
Jun 11 '10 at 19:51
source share



All Articles