Button.badge
From Opera 15 onward, Opera 11 & 12’s extension format is no longer supported, and instead, we’ve switched to Chromium’s extension model. Check out our new documentation for developing extensions for Opera 15 and higher and start building your own extensions.
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
This article is licensed under a Creative Commons Attribution 3.0 Unported license.
Comments