inicio sindicaci;ón
Jochem Prins: about search, Web2.0 and things I like

Cross-browser ‘bookmark this site’ script

I always thought that only Microsoft Internet Explorer supported a ‘bookmark this site’ functionality. By doing some research on the web I found a few code snippets that did the trick for other browsers as well. I compiled these scripts together in the following bookmarkthis(title, url) function. It’s completely cross-browser (compatible with IE4+, Firefox 1.x+ and Opera7+). Have fun with it!


function bookmarkthis(title,url) {
  if (window.sidebar) { // firefox
     window.sidebar.addPanel(title, url, "");
  } else if (document.all) { // IE
     window.external.AddFavorite(url, title);
  } 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();
  }
}

Niels said,

March 26, 2007 @ 6:35 pm

Thanks! It works indeed!

Btw, I always advise my visitors to press ctrl-D when they like my site. That’s a quick way to add the url to your bookmarks as well.

C L said,

March 26, 2007 @ 7:15 pm

Netscape (8.1.2) seems to want to add it to Sidebar instead of bookmarks.
Opera (9.10) doesn’t seem to do anything.

jochem said,

March 26, 2007 @ 10:07 pm

@C L,
Thanks, in turns out that Firefox opens the bookmarks in the sidebar as well. I didn’t check that… Too bad.
I’ll keep my eyes open for any other possibilities.

Siggi said,

April 30, 2007 @ 10:01 pm

Hi.

And, what’s on with other possibilities?
:-)

Has anyone find a snippet?

isoveli said,

May 21, 2007 @ 4:20 pm

Niels: Yes, if they’re using IE, it doesn’t bookmark i any other (real) browser

Layla said,

May 28, 2007 @ 4:52 pm

Basically identical to the script posted elsewhere…
http://www.dynamicdrive.com/dynamicindex9/addbook.htm
:)

Samiun said,

July 5, 2007 @ 9:33 pm

How to use this function?

Samiun said,

July 5, 2007 @ 9:54 pm

Done.. Its work http://www.stoplink.com

Thanks

miele said,

July 8, 2007 @ 11:33 am

nobody seems to know how to bookmark in firefox without using the sidebar. Isn’t there any way to bookmark in firefox properly?

Suhail said,

September 1, 2007 @ 11:16 am

hi
well i have used this script, but it doent work in opera 9.
it didnt bookmark the url.
please give me a script which also run in opera

RSS feed for comments on this post · TrackBack URI

Leave a Comment