简体   繁体   English

Firefox 扩展弹出窗口:关闭弹出窗口而不是窗口

[英]Firefox extension popup: close the popup not the window

I have create a chrome extension and now i wanna create an extension for firefox.我已经创建了一个 chrome 扩展,现在我想为 Firefox 创建一个扩展。 I use most of the code in chrome extension.我在 chrome 扩展中使用了大部分代码。

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.在 chrome 中,扩展程序可以在工具栏上有一个图标,当点击时,可以有一个弹出页面。 But there is no popup in firefox.但是firefox中没有弹出窗口。 I use a panel instead.我用panel代替。

And the question is how can i close the panel?问题是我如何关闭面板? I have used window.close() in the panel for some event.我在面板中使用了window.close()来处理某些事件。 But this will close the whole firefox window.但这将关闭整个 Firefox 窗口。

A panel is not a window - it is just a single tag in the XUL document (browser window's document in your case). panel不是窗口 - 它只是 XUL 文档(在您的情况下是浏览器窗口的文档)中的单个标签。 You should use the API provided for this tag to manipulate it, in particular the panel.hidePopup() method:您应该使用为此标签提供的 API 来操作它,特别是panel.hidePopup()方法:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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