views:

19

answers:

1

I have a sidebar inside my firefox addon. I want the following behavior for this sidebar - I should force close the sidebar if it is open when the browser is being closed (so that the next time the browser is opened the sidebar is not in an open state). I am trying to do this:

uninit: function() {
    var sidebarWindow = document.getElementById("sidebar").contentWindow;
    if (sidebarWindow.location.href == "chrome://myaddon/content/mysidebar.xul") {
        // Act on the sidebar content
        toggleSidebar('mySampleSidebar');
    }
}

I call this uninit for the window.unload event:

window.addEventListener("unload", function() { myobj.uninit()}, false);

Can someone tell me how to achieve this, as what I am trying to do is not working.

Thanks Kapil

A: 

In your firefox sidebar overlay javascript add

toggleSidebar();

in the "load" event listener function.

See here for example:

sidebar.onFirefoxLoad = function(event) {
  document.getElementById("contentAreaContextMenu")
          .addEventListener("popupshowing", function (e) 
             { sidebar.showFirefoxContextMenu(e); }, false);

           toggleSidebar();
};

window.addEventListener("load", sidebar.onFirefoxLoad, false);
Vinothkumar Arputharaj