``` More examples can be found at the"> ``` More examples can be found at the" />
Easy Tutorial
❮ Dom Obj Del Dom Obj Url ❯

oncanplay Event

Event Object

Example

Execute JavaScript when a video is ready to start playing:

<video oncanplay="myFunction()">

More examples can be found at the bottom of this page.


Definition and Usage

The oncanplay event is triggered when the user can start playing the audio/video.

During the loading process of the audio/video, the events are triggered in the following order:


Browser Support

The numbers in the table specify the first browser version that supports the event.

Event
oncanplay Yes 9.0 Yes Yes Yes

Syntax

In HTML:

In JavaScript:

In JavaScript, using the addEventListener() method:

Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.


Bubbles: No
Cancelable: No
--- ---
Event type: Event
--- ---
Supported HTML tags: <audio>, <video>
--- ---

More Examples

Example

Execute JavaScript when an audio is ready to play:

<audio oncanplay="myFunction()">

❮ Dom Obj Del Dom Obj Url ❯