html tutorial - oncanplay Attribute in HTML - html5 - html code - html form

Oncanplay attribute in html

Learn html - html tutorial - Oncanplay attribute in html - html examples - html programs

  • The oncanplay attribute is used to execute a script when the browser can starts playing the specific media file.

Syntax for oncanplay attribute in HTML:

<element oncanplay="script">

Differences between HTML 4.01 and HTML5 for oncanplay attribute:

HTML 4.01


Applies To:

Elements Attribute
<audio> form
<video> form

Attribute Values:

Value Description
script The script to be run on oncanplay

Sample Coding for oncanplay Attribute in HTML:

Tryit<!DOCTYPE html>
        <title>Wikitechy oncanplay  attribute</title>
        <video width="320" height="240" controls oncanplay="onCanPlay()">
        <source src="hibiscus.mp4" type="video/mp4">
        function onCanPlay()
          alert("Wikitechy Video Can Play Now!");

Code Explanation for oncanplay Attribute in HTML:

 oncanplay  Attribute Code Explanation

  1. <video> tag is used to embed a video file in the HTML Document.
  2. The oncanplay attribute is used to trigger an event when the video can be ready to play.
  3. The JavaScript function oncanplay is used to display an alert message.

Output for oncanplay Attribute in HTML:

oncanplay Attribute Tag Output

  1. The output shows the video file can be played, so the alert message displayed as “Wikitechy Video Can Play Now!”.

Browser Support for oncanplay Attribute in HTML:

Yes 9.0 Yes Yes Yes

Related Searches to oncanplay attribute in html

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add to your ad blocking whitelist or disable your adblocking software.