action.getBadgeBackgroundColor()
语法
js
browser.action.getBadgeBackgroundColor(
details // 对象
)
参数
details
-
一个拥有下列属性的对象:
tabId
可选-
integer
,指定要获取徽章背景颜色的标签页。 windowId
可选-
integer
,指定要获取徽章背景颜色的窗口。
- 若同时指定了
windowId
和tabId
,则函数出错。 - 若同时未指定
windowId
和tabId
,则返回全局徽章的背景颜色。
返回值
一个 Promise
,会兑现表示获取到的颜色的 action.ColorArray
。
示例
输出徽章的背景颜色:
js
function onGot(color) {
console.log(color);
}
function onFailure(error) {
console.log(error);
}
browser.action.getBadgeBackgroundColor({}).then(onGot, onFailure);
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | ||||||
---|---|---|---|---|---|---|---|
getBadgeBackgroundColor | |||||||
details.windowId parameter |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Partial support
- Partial 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
。