We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

scarfboy on 07/17/08


Tagged

javascript bookmarks


Versions (?)


Who likes this?

3 people have marked this snippet as a favorite

SpinZ
wizard04
jonhenshaw


Javascript add-to-bookmarks (Firefox, IE)


Published in: JavaScript 


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

  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 

You need to login to post a comment.