Developers › Dev.Opera

opera.contexts.toolbar.removeItem()

December 6, 2011 · by Opera Software

Description

This method removes a given Button from the toolbar in the browser.

Parameters:

  • item: The Button to be removed.

Syntax:

void removeItem (<Button> item)

Example:

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

// Create a button
var button = opera.contexts.toolbar.createItem({
  title: 'Weather Extension',
  icon: 'yr.png'
});

// Add it to the browser toolbar
opera.contexts.toolbar.addItem( button );

// Remove the button for a few seconds when someone clicks it
button.addEventListener('click', handleClick, false);
function handleClick() {
  // Remove the button
  opera.contexts.toolbar.removeItem(button);

  // but add it back after a short while
  setTimeout(function() {	
    opera.contexts.toolbar.addItem(button);			
  }, 500);
}

About this article

Published inDev.Opera
DateDecember 6, 2011
AuthorOpera Software
TagsButton and Badge, extensions API, Toolbar
OriginalInternet Archive