« Documentation Home

Button.badge

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

This property represents the Badge for the button.

Example:

You can reference and update the badge properties directly from the button object (e.g. button.badge.textContent = 42) or through the badge object.

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

// Create a button
var button = opera.contexts.toolbar.createItem({
  title:'My Extension',
  icon:'icon.18x18.png',
  badge: {}
});

// Add it to the browser UI
opera.contexts.toolbar.addItem(button);

// Set the badge and the font colors
var badge = button.badge; 
badge.backgroundColor = '#5566ff';
badge.color = "#ffffff";

// Update badge properties directly through the button object
button.badge.textContent = 42;

// Get the background color?
var badgeColor = button.badge.backgroundColor; // this was set to '#5566ff' above