Search code examples
javascriptcross-browserbookmarks

bookmark feature opening as a sidebar


HI, I have implemented a Bookmark feature in my website, but when I click on the bookmark link from the toolbar, its opening as a new window in a sidebar instead as an new page in mozilla firefox,

It is working accordingly in IE, Can any one please help me in this


Solution

  • AFAIK, you cannot change the behavior of your script, because firefox doesn't expose in its JavaScript API for websites a function for creating bookmarks. Firefox only allows you to create a small page, that can be then opened in the sidebar. For that there is an API that you are currently using.

    window.sidebar.addPanel(title, url, "");
    

    If your website was running in a privileged environment (which is the case for firefox addons), it would be possible to use the bookmarkmanager.

    Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"]
              .getService(Components.interfaces.nsINavBookmarksService);