pageAction.setPopup()

Sets the HTML document to be opened as a popup when the user clicks on the page action's icon.

Syntax

browser.pageAction.setPopup(
  details // object
)

Parameters

details
object.
tabId
integer. The ID of the tab for which you want to set the popup.
popup
string. URL to the HTML file to show in a popup. If set to an empty string (''), no popup is shown.

Browser compatibility

ChromeEdgeFirefoxFirefox for AndroidOpera
Basic supportYesYes4550 1Yes
1. The 'tabId' parameter is ignored, and the popup is set for all tabs.

Examples

Listen for tabs.onUpdated events, and switch the popup if the loading status changes:

browser.tabs.onUpdated.addListener((tabId, changeInfo, tabInfo) => {
  if (changeInfo.status) {
    browser.pageAction.show(tabId);
    if (changeInfo.status == "loading") {
      browser.pageAction.setPopup({
        tabId,
        popup: "/popup/loading.html"
      });
    } else {
      browser.pageAction.setPopup({
        tabId,
        popup: "/popup/complete.html"
      });
    }
  }
});

Acknowledgements

This API is based on Chromium's chrome.pageAction API. This documentation is derived from page_action.json in the Chromium code.

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

Document Tags and Contributors

 Contributors to this page: wbamberg, Makyen, chrisdavidmills
 Last updated by: wbamberg,