pageAction.setPopup()
Sets the HTML document to be opened as a popup when the user clicks on the page action's icon.
Syntax
js
browser.pageAction.setPopup(
details // object
)
Parameters
details-
object.tabId-
integer. The ID of the tab for which you want to set the popup. popup-
stringornull. 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.onClickedevents.If
nullis passed here, the popup is reset to the popup that was specified in thepage_actionmanifest key.
Examples
Listen for tabs.onUpdated events, and switch the popup if the loading status changes:
js
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",
});
}
}
});
Browser compatibility
Loading…
Note:
This API is based on Chromium's chrome.pageAction API. This documentation is derived from page_action.json in the Chromium code.