Back to Content

browserAction.openPopup()

files/en-us/mozilla/add-ons/webextensions/api/browseraction/openpopup/index.md

latest1.0 KB
Original Source

Open the browser action's popup.

Syntax

js-nolint
browser.browserAction.openPopup(
  options // optional object
)

Parameters

  • details {{optional_inline}}
    • : An object with these properties:
      • windowId {{optional_inline}}
        • : integer. Window to open the popup in. Defaults to the focused (active) window. In Chrome and from Firefox 149, if the window ID is for an unfocused window, the API call is rejected. A window can be focused by calling {{WebExtAPIRef("windows.update")}} with focused: true.

Return value

A Promise that resolves with no arguments. If the popup isn't opened, rejects with an error message.

Examples

Open the popup when the user selects a context menu item:

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

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

{{WebExtExamples}}

Browser compatibility

{{Compat}}