The Ultimate Add Bookmark Script

This cross-browser, cross-platform script guides a user in adding your page as a bookmark (aka favorite) in their browser. It is written using unobtrusive JavaScript techniques so that if JavaScript support is not enabled, the link will not be present, thus preventing confusion in any user (of a browser that does not have JavaScript support enabled) who clicks the link with no result. It works in IE5+/Win, Firefox, Netscape 6+, Opera 7+, Safari, Google Chrome (for Windows), Konqueror 3, IE5/Mac, and iCab 3.

What Makes This Script Different?

Besides using unobtrusive JavaScript, the main difference is that it is made to do something relatively useful in more browsers than just IE/Win, Firefox, and/or Opera 7+.

Many similar scripts use window.sidebar.addPanel() or rel="sidebar" to add a bookmark in Firefox. There's just one problem with those two methods — they add a bookmark that is set to open in the sidebar (panel) by default instead of opening in the window/tab like a normal bookmark. rel="sidebar" works fine in Opera 7+, because in the dialog window there is an option to make the bookmark open in the sidebar or not. Firefox doesn't provide that option in the dialog window; to change it you have to open the properties of the bookmark.

How To Get The Script

If you would like to use this script on a commercial site, please contact us to discuss pricing.

You can download the script here.

How To Use The Script

The script looks for an element with the ID attribute set to "addBookmarkContainer" and appends a new link (<a>) element as a child of it.

This is an example of the code needed to use this script on a page:
<script type="text/javascript" src="/js/add_bookmark.js">
</script>
<p id="addBookmarkContainer"></p>

Demonstration

Updates

I've now updated the script so that you can use it to create multiple links on the same page, by passing different IDs to each function call you make to it. You can also create image links as well as plain text links.

Last update: 2010-03-05