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



Onended attribute in html

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

  • The onended event triggers when the audio/video has been ended.
  • The onended attribute is a section of the Event Attributes.

Syntax for onended attribute in HTML:

<element onended=”script”>

Applies To:

Elements Attribute
<audio> onended
<video> onended

onended Attribute Value:

Value Description
script The script can run on onended.

Sample Coding for onended Attribute in HTML:

Tryit<!DOCTYPE html>
<html>
    <head>
        <title>Wikitechy onended attribute</title>
    </head>
    <body>
        <video width="320" height="240" controls onended="onEnded()">
           <source src="hibiscus.mp4" type="video/mp4">
        </video>
        <script>
          function onEnded() 
          {
            alert("Thank you for Watching Wikitechy video");
          }
        </script>
    </body>
</html>

Code Explanation for onended Attribute in HTML:

onended Attribute Code Explanation

  1. <video> tag is used to embed a video file in the HTML Document.
  2. The onended attribute is used to call onEnded() JavaScript function when the video reaches its end.
  3. The JavaScript function onEnded is used to display an alert message.

Output for onended Attribute in HTML:

onended Attribute Output

  1. The video file has been displayed.
  2. onended Attribute Output
  3. After ending the video, the alert box display the message as “Thank you for Watching Wikitechy video”.

Browser Support for onended Attribute in HTML:

Yes Yes Yes Yes Yes

Related Searches to onended Attribute in html