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.


This method is used to listen for events being dispatched. For opera.extension, this includes 'connect', 'message', and 'disconnect'.


  • type: Type of event; allowed values are: "message", "disconnect", and "connect".
  • eventListener: The function to be executed when the event occurs.
  • useCapture: Boolean, keep false for now; note: this value currently has no purpose.


void addEventListener (<DOMString> type, eventListener, <boolean> useCapture)


// The background process ('/background.js').

// Listen for a new environment being created (like the popup window)
opera.extension.addEventListener('connect', function(event) {
  var connected = true;
}, false);

// Listen for messages being sent
opera.extension.addEventListener('message', function(event) {
  var message = event.data;
}, false);

// Listen for environments being destroyed (and communication disabled)
opera.extension.addEventListener('disconnect', function(event) {
  var connected = false;
}, false);

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


No new comments accepted.