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 method creates a Button
from a given property object. Note: The item can only be used within the ToolbarContext
that it is created in.
properties
: The ButtonProperties
to use when creating the Button
.The available properties include:
Button createItem (<ButtonProperties> properties)
The below button would include a badge (saying '42') and display a popup window when clicked.
Note that buttons must be defined in the background process (e.g. in index.html) in order to work.
//
// The background process (e.g. index.html)
//
var i = 0; // count the number of times the button get clicked
// The button properties
var properties = {
disabled: false,
title: "My Extension",
icon: "icon.18x18.png",
onclick: function() {
i++; // counting how often the button is clicked
},
popup: {
href: 'popup.html',
width: 100,
height: 100
},
badge: {
display: 'block',
backgroundColor: '#5566ff',
color: '#ffffff',
textContent: '42'
}
};
// Create the button
var button = opera.contexts.toolbar.createItem(properties);
You can also define the properties on the fly when creating the button:
//
// The background process (e.g. index.html)
//
// Create a button
var button = opera.contexts.toolbar.createItem({
title: 'Weather Extension',
icon: 'yr.png'
});