简体   繁体   中英

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.

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();

using

window.close()

tested in FF 70/71

ref to https://discourse.mozilla.org/t/how-to-close-popup-browser-window/13977/4

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM