Gets the URL for the HTML document set as the popup for this page action.
This is an asynchronous function that returns a Promise
.
Gets the URL for the HTML document set as the popup for this page action.
This is an asynchronous function that returns a Promise
.
let gettingPopup = browser.pageAction.getPopup(
details // object
)
details
object
.
tabId
integer
. ID of the tab whose popup you want to get.
A Promise
that will be fulfilled with a string containing the popup's URL.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
getPopup |
Yes | 14 | 45 | ? | Yes | 14 | ? | ? |
50The 'tabId' parameter is ignored: the page action popup is the same for all tabs. |
? | 15 | ? |
Add a context menu item that logs the popup URL for the current tab. Note that you'll need the contextMenus
permission in your manifest to create context menu items.
function gotPopup(popupURL) {
console.log(popupURL);
}
browser.contextMenus.create({
id: "get-popup",
title: "Get popup URL"
});
browser.contextMenus.onClicked.addListener((info, tab) => {
if (info.menuItemId === "get-popup") {
let gettingPopup = browser.pageAction.getPopup({tabId: tab.id});
gettingPopup.then(gotPopup);
}
});
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/getPopup