HTML oncanplay Attribute


Definition and Usage

The oncanplay attribute defines a script to run when the browser can start playing the specified media (when it has buffered enough to begin).


Applies to

The oncanplay attribute is part of the Event Attributes, and can be used on the following elements:

Elements Event
<audio> canplay
<embed> canplay
<object> canplay
<video> canplay

Examples

Audio Example

Run "myFunction" when the audio is ready to start playing:

<audio oncanplay="myFunction()">
Try it Yourself »

Video Example

Run "myFunction" when the video is ready to start playing:

<video oncanplay="myFunction()">
Try it Yourself »

Browser Support

The oncanplay attribute has the following browser support for each element:

Element
audio Yes 9.0 Yes Yes Yes
embed Not supported Not supported Not supported Not supported Not supported
object Not supported Not supported Not supported Not supported Not supported
video Yes 9.0 Yes Yes Yes

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.