« Documentation Home

Badge.color

This documentation relates to Opera's now deprecated .oex Extension API framework for Opera versions <= 12.15 and also provided by our OEX2NEX shim library.

For the latest Opera Extensions API documentation for Opera versions > 12.15 please consult the latest Opera Extensions API documentation online.

Description:

The color of the text of the badge; accepts hexadecimal notation, RGBA and color name values (e.g., #afafaf, (200, 200, 200, 0), blue).

Example:

//
// The background process (e.g. index.html)
//

// Set the button's properties
var properties = {
  disabled: false,
  title: "My Test Extension",
  icon: "icon.18x18.png",
  badge: {
    backgroundColor: '#5566ff',
    color: 'white',
    textContent: '42'
  }
};	

// Add the button to the browser UI
var button = opera.contexts.toolbar.createItem(properties);
opera.contexts.toolbar.addItem(button);

// Change the badge's font color each time the button is clicked
var i = 1; 
button.addEventListener('click', handleClick, false);

function handleClick() {
  var fontColor = (i % 2) ? '#ffffff' : '#000000';
  button.badge.color = fontColor;
  i++;
}