语法
js
browser.browserAction.getBadgeBackgroundColor(
details // object
)
参数
details-
具有以下属性的对象:
tabId可选-
integer。指定从中获取徽章背景颜色的标签页。 windowId可选-
integer。指定从中获取徽章背景的窗口。
- 如果同时提供了
windowId和tabId,则函数将失败。 - 如果同时省略了
windowId和tabId,则返回全局徽章背景色。
返回值
一个 Promise,它将以 browserAction.ColorArray 格式的检索到的颜色来 fulfilled。
示例
记录徽章的背景颜色
js
function onGot(color) {
console.log(color);
}
function onFailure(error) {
console.log(error);
}
browser.browserAction.getBadgeBackgroundColor({}).then(onGot, onFailure);
浏览器兼容性
加载中…
注意:此 API 基于 Chromium 的 chrome.browserAction API。此文档源自 Chromium 代码中的 browser_action.json。