Sets the HTML document to be opened as a popup when the user clicks on the page action's icon.
On this page
pageAction.setPopup()
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
ornull
. URL to the HTML file to show in a popup.If an empty string (
""
) is passed here, the popup is disabled, and the extension will receivepageAction.onClicked
events.If
null
is passed here, the popup is reset to the popup that was specified in thepage_action
manifest key.
-
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
setPopup |
Yes | 14 | 45 | ? | Yes | 14 | ? | ? |
50The 'tabId' parameter is ignored, and the popup is set for all tabs. |
? | 15 | ? |
null |
No | No | 59 | ? | No | 14 | ? | ? | No | ? | 15 | ? |
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"
});
}
}
});
Note: This API is based on Chromium's chrome.pageAction
API. This documentation is derived from page_action.json
in the Chromium code.
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/pageAction/setPopup