Button.popup

By Opera Software

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 Popup for the Button. Calling Button.popup will return the popup object. You can also get and set the popup properties directly through the Button object (e.g. to set the popup width you can do 'button.popup.width = 300')

Example:

The below example shows a popup when the button is clicked. The content of the popup changes between one of three websites each time the popup is diplayed.

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

// Set the button's properties
var properties = {
  disabled: false,
  title: "My Extension",
  icon: "icon.18x18.png",
  popup: {
    href: 'popup.html',
    width: 300
  }
};

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

// Get the popup object to set the height property
var popup = button.popup;
popup.height = 400;

// Open a site randomly in the popup when the button is clicked
var randomSites = ['http://touch.facebook.com', 'http://mobile.twitter.com', 'http://m.opera.com/'];
var i = 1;
button.addEventListener('click', handleClick, false);

function handleClick(){
  // Circle through the sites on each click
  button.popup.href = randomSites[i % 3];
  i++;
}

This article is licensed under a Creative Commons Attribution 3.0 Unported license.

Comments

No new comments accepted.