Content
Introduction
Usually bookmarks are added manually by users, but sometimes you want to place a button on the web page that, when clicked, automatically adds a new bookmark. For example if you embed a website using iframes into another website, the user cannot add a bookmark to the embedded website. A button that adds a bookmark automatically would be useful.
Wrong Solution
When you browse through the net, you very often find the following Javascript code to add bookmarks to Firefox:
window.sidebar.addPanel("example.org", "http://www.example.org/","");
This code really adds a bookmark named example.org to the bookmark folder. But when you select the bookmark, the URL is opended in the sidebar instead of in the main window.

- Often used Javascript code adds bookmarks that open URL in the Firefox sidebar.
Try it, use the button below:
See that the property page of the bookmark has "Load this bookmark in the sidebar" checked.

- The bookmark property page has "Load this bookmark in the sidebar" checked
Right Solution
The solution to this problem can be found in the Firefox DOM documentation. See the following links:
- https://developer.mozilla.org/en/Manipulating_bookmarks_using_Places#Creating_a_new_bookmark
- https://developer.mozilla.org/En/Code_snippets/Bookmarks
Or try the button below:
Ususally nothing happens when you click on the button above. This is because of the security settings in Firefox. For the button to work you have to lower the security settings or, for a production web site, you have to sign the script. See the following link:
