Advertisement
Home Open Editor ❯

HTML oncanplay Attribute

Example

//Accessing the element
var vid = document.getElementById("myVideo");

//Creating a function
vid.oncanplay = function() {
  alert("The video can start playing");
};

Try this code ❯

Meaning

The canplay event run when the browser can start playing the audio/video.


Standard Syntax

<element oncanplay="script">


Applies to:

The oncanplay attribute can be used on the following element:

Element Attribute
<audio> oncanplay
<embed> oncanplay
<object> oncanplay
<video> oncanplay

Advertisement

Attribute Values

Value Description
script Specifies the script to be run on oncanplay.
Home Open Editor ❯
Advertisement