sidebarAction.getPanel()
获取定义侧边栏内容的 HTML 文档的 URL。
这是一个返回 Promise
的异步函数。
语法
js
let gettingPanel = browser.sidebarAction.getPanel(
details // 对象
)
参数
details
-
object
。包含下列属性的对象:tabId
可选-
integer
。获取特定于给定标签页的侧边栏的面板。 windowId
可选-
integer
。获取特定于给定窗口的侧边栏的面板。
- 如果同时提供了
windowId
和tabId
,函数将失败且返回的 promise 将被拒绝。 - 如果同时省略
windowId
和tabId
,则返回全局面板。
返回值
Promise
,将用包含侧边栏面板的文档的 URL 来兑现。这将是一个完全限定 URL,例如:
url
moz-extension:/sidebar.html
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
getPanel |
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.
示例
获取面板的 URL:
js
function onGot(sidebarUrl) {
console.log(sidebarUrl);
}
let gettingPanel = browser.sidebarAction.getPanel({});
gettingPanel.then(onGot);
备注:
此 API 基于 Opera 的 chrome.sidebarAction
API。