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.
This method is used to listen for events being dispatched. For opera.extension
, this inlcudes '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, eventListerner, <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);