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




onplaying attribute in html

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

  • The onplaying attributes trigger an event when the audio/video have started playing.
  • The onplaying attribute is part of an Event Attributes.

Syntax for onplaying attribute in HTML:

<element onplaying=”script”>

Applies To:

Elements Attribute
<audio> onplaying
<video> onplaying

onplaying Attribute Value:

Value Description
script The script to be run on onplaying

Sample Coding for onplaying Attribute in HTML:

Tryit<!DOCTYPE html>
<html>
    <head>
        <title>Wikitechy HTML onplaying attribute</title>
    </head>
    <body>
        <h1>Wikitechy HTML onplaying attribute</h1>
            <audio controls onplaying=”myFunction()”>
                <source src=”welcome.wav” type="audio/wav">
                <source src=”welcome.mp3” type="audio/mp3">
            </audio>
            <script>
                function myFunction()  
                {
                  alert(“The Wikitechy audio have started playing”);
                }
            </script>
    </body>
</html>

Code Explanation for onplaying Attribute in HTML:

onplaying Attribute Code Explanation

  1. The onplaying attributes is used to run “onPlaying()” function when the audio file is being played.
  2. The <source> tag is used to give the location of the audio files
  3. The function onPlaying() is used to display the alert message as “The Wikitechy audio have started playing!”

Output for onplaying Attribute in HTML:

onplaying Attribute Output

  1. If user play the audio file, the alert box will appear on the screen.

Browser Support for onplaying Attribute in HTML:

Yes 9.0 Yes Yes Yes

Related Searches to onplaying Attribute in html