Button.removeEventListener()
Description:
This method removes a listener from receiving an event.
Parameters:
type: Type of event; allowed values are:clickandremove.eventListener: The function to be removed.useCapture: Boolean; should be kept asfalsefor now. Note: this value currently has no purpose.
Syntax:
void removeEventListener()
Example:
//
// The background process (e.g. index.html)
//
// Set the button's properties
var properties = {
disabled: false,
title: "My Test Extension",
icon: "icon.18x18.png"
};
// Add the button to the browser UI
var button = opera.contexts.toolbar.createItem(properties);
opera.contexts.toolbar.addItem(button);
// Attach the click handler to the button
var i = 1;
button.addEventListener('click', handleClick, false);
function handleClick() {
// If clicked more than five times, stop counting.
if (i > 5) {
button.title = "You've clicked the button more than 5 times";
button.removeEventListener('click', handleClick, false);
return;
}
// Update the button title
button.title = "You've clicked the button " + i + " time(s)";
i++;
}
This article is licensed under a Creative Commons Attribution 3.0 Unported license.
Comments
No new comments accepted.