Button.icon
Description
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.
Example:
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++;
}
This article is licensed under a Creative Commons Attribution 3.0 Unported license.
Comments
You must be logged in to write a comment. If you're not a registered member, please sign up.