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

Oncanplaythrough attribute in html

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

  • The oncanplaythrough event happens when the web browser evaluates it can play through the specified audio/video without having to stop for buffering.
  • The oncanplaythrough attribute is section of the Event Attributes.

Syntax for oncanplaythrough attribute in HTML:

<element oncanplaythrough="Script">

Difference between HTML 4.01 and HTML 5 for oncanplaythrough Attribute:

HTML 4.01


Applies To:

Elements Attribute
<audio> oncanplaythrough
<video> oncanplaythrough

oncanplaythrough Attribute Values:

Value Description
script The script to be run on oncanplaythrough.

Sample Coding for oncanplaythrough Attribute in HTML:

Tryit<!DOCTYPE html>
        <title>Wikitechy oncanplaythrough attribute</title>
    <video width="320" height="240" controls oncanplaythrough="onCanPlayThrough()">
        <source src="hibiscus.mp4" type="video/mp4">
        function onCanPlayThrough() {
            alert("Wikitechy Video Can be Played Fully!");

Code Explanation for oncanplaythrough Attribute in HTML:

oncanplaythrough Attribute Code Explanation

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

Output for oncanplaythrough Attribute in HTML:

oncanplaythrough Attribute Output

  1. The alert message shows when media file has been fully buffered.

Browser Support for oncanplaythrough Attribute in HTML:

Yes 9.0 Yes Yes Yes

Related Searches to oncanplaythrough Attribute in html