javascriptfirefoxfirefox-addonxul

Firefox extension popup: close the popup not the window


I have create a chrome extension and now i wanna create an extension for firefox. I use most of the code in chrome extension.

But now i encountered a problem. In chrome, extension can have an icon on the toolbar and when clicked, there can be a popup page. But there is no popup in firefox. I use a panel instead.

And the question is how can i close the panel? I have used window.close() in the panel for some event. But this will close the whole firefox window.


Solution

  • A panel is not a window - it is just a single tag in the XUL document (browser window's document in your case). You should use the API provided for this tag to manipulate it, in particular the panel.hidePopup() method:

    document.getElementById("my-panel").hidePopup();