我们的志愿者还没有将这篇文章翻译为 中文 (简体)加入我们帮助完成翻译
您也可以阅读此文章的English (US)版。

Gets the HTML document set as the popup for this browser action.

This is an asynchronous function that returns a Promise.

Syntax

var gettingPopup = browser.browserAction.getPopup(
  details               // object
)

Parameters

details
object.
tabIdOptional
integer. The tab whose popup to get.
windowIdOptional
integer. The windows whose popup to get.
  • If windowId and tabId are both supplied, the function fails.
  • If windowId and tabId are both omitted, the global popup is returned.

Return value

A Promise that will be fulfilled with a string containing the URL for the popup's document. This will be a fully qualifed URL, such as moz-extension://d1d8a2eb-fe60-f646-af30-a866c5b39942/popups/popup2.html.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxOperaFirefox for Android
getPopupChrome Full support YesEdge No support NoFirefox Full support 45Opera Full support YesFirefox Android Full support 57
details.windowIdChrome No support NoEdge No support NoFirefox Full support 62Opera No support NoFirefox Android No support No

Legend

Full support  
Full support
No support  
No support

Examples

Get the popup's URL:

function gotPopup(popupURL) {
  console.log(popupURL)
}

var gettingPopup = browser.browserAction.getPopup({});
gettingPopup.then(gotPopup); 
Acknowledgements

This API is based on Chromium's chrome.browserAction API. This documentation is derived from browser_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.

文档标签和贡献者

最后编辑者: mdnwebdocs-bot,