browserAction.openPopup()

打开浏览操作的弹出窗口。

在稳定版本的 Firefox 中,你只能在用户操作的处理器内调用此函数。有关详细信息,请参见浏览器兼容性

语法

js
browser.browserAction.openPopup(
  options // 可选对象
)

参数

details 可选

一个包含以下属性的对象:

windowId 可选

integer。要为其打开弹出窗口的窗口。默认为当前窗口。

返回值

一个 Promise,兑现时不带任何参数。

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
openPopup

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support
See implementation notes.
User must explicitly enable this feature.

示例

当用户选择上下文菜单项时,打开弹出窗口:

js
browser.menus.create({
  id: "open-popup",
  title: "open popup",
  contexts: ["all"],
});

browser.menus.onClicked.addListener(() => {
  browser.browserAction.openPopup();
});