addEventListener()
Adds a listener for a custom event type or a standard event type when the event is fired. This method adds a listener for custom event types in API version 25.0 or later; it adds a listener for standard event types in API version 30.0 or later.
For the list of standard events, see Methods for Console Events.
| Name | Type | Description |
|---|---|---|
eventType | string | Custom event type for which eventListener listens. |
eventListener | function | JavaScript method called when an eventType is fired. |
additionalParams | object | Optional parameters accepted by this method. The supported properties on this object are tabId: The ID of the tab to listen for the specified event. This argument is only available in API version 30.0 or later. |
This method is asynchronous, so it returns its response in an object in a callback method. The response object contains the following field:
| Name | Type | Description |
|---|---|---|
message | string | The message which is sent with the fired event. If the response is from a custom keyboard shortcut, the message includes the following information on which the browser is focused, in this order:
|
This method is asynchronous, so it returns its response in an object in a callback method. The response object contains the following field:
| Name | Type | Description |
|---|---|---|
message | string | The message which is sent with the fired event. If the response is from a console event, the message includes payload details as described in Methods for Console Events. If the response is from a custom keyboard shortcut, the message includes the following information on which the browser is focused, in this order:
|