Badge.backgroundColor
Description:
The background color for the badge; accepts hexadecimal notation, RGBA, and color name values (e.g., #afafaf, (200, 200, 200, 0), blue).
Example:
//
// The background process (index.html)
//
// Set the button's properties
var properties = {
disabled: false,
title: "My Test Extension",
icon: "icon.18x18.png",
badge: {
backgroundColor: 'blue',
color: '#ffffff',
textContent: '42'
}
};
// Add the button to the browser UI
var button = opera.contexts.toolbar.createItem(properties);
opera.contexts.toolbar.addItem(button);
// Change the background color of the badge with each button click
var i = 1;
button.addEventListener('click', handleClick, false);
function handleClick() {
var badgeColor = (i % 2) ? '#5566ff' : '#cc5555';
button.badge.backgroundColor = badgeColor;
i++;
}About this article
| Published in | Dev.Opera |
|---|---|
| Date | December 6, 2011 |
| Author | Opera Software |
| Tags | Button and Badge, extensions API, Toolbar |
| Original | Internet Archive |