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.
This property represents the icon for the Button
. It can reference the relative path to a data URI, an image located inside the package, or it can point to an external URL.
The below example changes the button icon on each click.
//
// The background process (e.g. index.html)
//
// Create a button and add it to the browser UI
var properties = {
title: "My Extension",
icon: "icon.18x18.png",
};
var button = opera.contexts.toolbar.createItem(properties);
opera.contexts.toolbar.addItem(button);
// Track how many times the button has been clicked
var i = 1;
// Handle button clicks
button.addEventListener('click', handleClick, false);
// Change the icon to 'icon2' every time the click count is an even number
function handleClick() {
if (i % 2 == 1) {
button.icon = "icon2.18x18.png";
} else {
button.icon = "icon.18x18.png";
}
// Increase the click count
i++;
}