语法
js
browser.browserAction.getBadgeBackgroundColor(
details // 对象
)
参数
details-
包含以下属性的对象:
tabId可选-
integer。指定从中获取徽章背景颜色的标签页。 windowId可选-
integer。指定从中获取徽章背景颜色的窗口。
- 如果同时提供了
windowId和tabId,则函数失败。 - 如果
windowId和tabId都省略,则返回全局徽章背景颜色。
返回值
一个 Promise,其会兑现一个包含了检索到的颜色的 browserAction.ColorArray。
浏览器兼容性
Loading…
示例
记录徽章的背景颜色:
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。