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
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
Report problems with this compatibility data on GitHubwebextensions-desktop | webextensions-mobile | |||||
---|---|---|---|---|---|---|
setPopup | ChromeFull supportYes | EdgeFull support14 | FirefoxFull support45 | OperaFull supportYes | SafariFull support14 | Firefox for AndroidFull support50
|
The popup property of the details parameter can be set to null . | ChromeNo supportNo | EdgeNo supportNo | FirefoxFull support59 | OperaNo supportNo | SafariFull support14 | Firefox for AndroidNo supportNo |
Legend
- Full support
- Full support
- No support
- No support
- See implementation notes.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
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.