Javascript add-to-bookmarks (Firefox, IE)


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

There is no standard for this at all - this just looks for the hooks that exist in IE and gecko-type browsers.
See also http://msdn.microsoft.com/en-us/library/ms535926(VS.85).aspx and http://developer.mozilla.org/en/docs/DOM:window.sidebar


Copy this code and paste it in your HTML
  1. function addToBookmarks(url,title) {
  2. if (window.external && window.external.AddFavorite)
  3. window.external.AddFavorite(url,title); // IE4 and later
  4. else if (window.sidebar && window.sidebar.addPanel)
  5. window.sidebar.addPanel(title,url,''); // Gecko/firefox
  6. }
  7.  
  8. //use e.g. like:
  9. addToBookmarks(window.document.location, window.document.title);

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.