action.getPopup()
语法
js
let gettingPopup = browser.action.getPopup(
details // 对象
)
参数
details
-
一个含有下列属性的对象:
tabId
可选-
integer
,指定要获取弹窗的标签页。 windowId
可选-
integer
,指定要获取弹窗的窗口。
- 若同时指定了
windowId
和tabId
,则函数出错。 - 若同时未指定
windowId
和tabId
,则返回全局弹窗。
返回值
一个 Promise
,会兑现包含弹窗文档的 URL 的字符串。该 URL 是完全限定 URL,例如 moz-extension://d1d8a2eb-fe60-f646-af30-a866c5b39942/popups/popup2.html
。
示例
获取弹窗的 URL:
js
function gotPopup(popupURL) {
console.log(popupURL);
}
let gettingPopup = browser.action.getPopup({});
gettingPopup.then(gotPopup);
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
getPopup | |||||||
details.windowId parameter |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
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.
备注:
该 API 基于 Chromium 的 chrome.action
API。该文档衍生自 Chromium 代码中的 browser_action.json
。