« Documentation Home

Button.onclick

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 function executed when the button is clicked.

Example:

The below example opens a new tab when the extension's button is clicked.

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

// Set the button's properties
var properties = {
  disabled: false,
  title: "My Extension",
  icon: "images/icon_18.png",
  onclick: function() {
    var tab = opera.extension.tabs.create();
  }
};	

// Create and add the button to the toolbar
var button = opera.contexts.toolbar.createItem(properties);
opera.contexts.toolbar.addItem(button);