The Event object defines the basic OpenTok event object that is passed to
event listeners. Other OpenTok event classes implement the properties and methods of
the Event object.
For example, the Stream object dispatches a streamPropertyChanged
event when
the stream's properties are updated. You add a callback for an event using the
on()
method of the Stream object:
stream.on("streamPropertyChanged", function (event) {
alert("Properties changed for stream " + event.target.streamId);
});
Properties
Name | Type | Description |
---|---|---|
cancelable |
Boolean | Whether the event has a default behavior that is cancelable
(true ) or not (false ). You can cancel the default behavior by
calling the preventDefault() method of the Event object in the callback
function. (See preventDefault().) |
target |
Object | The object that dispatched the event. |
type |
String | The type of event. |
Methods
Name | Description |
---|---|
isDefaultPrevented() → {Boolean} |
Whether the default event behavior has been prevented via a call to
preventDefault() (true ) or not (false ). |
preventDefault() |
Prevents the default behavior associated with the event from taking place. |
isDefaultPrevented() → {Boolean}
Whether the default event behavior has been prevented via a call to
preventDefault()
(true
) or not (false
).
See preventDefault().
Returns:
preventDefault()
Prevents the default behavior associated with the event from taking place.
To see whether an event has a default behavior, check the cancelable
property
of the event object.
Call the preventDefault()
method in the callback function for the event.
The following events have default behaviors:
sessionDisconnect
— See SessionDisconnectEvent.preventDefault().streamDestroyed
— See StreamEvent.preventDefault().accessDialogOpened
— See the accessDialogOpened event.accessDenied
— See the accessDenied event.