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

Onpause attribute in html

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

  • onpause attribute used trigger an event when the audio/video is paused either by the user or programmatically.
  • The onpause attribute is a part of the Event attribute.

Syntax for onpause attribute in HTML:

<element onpause="script">

Applies To:

Elements Attribute
<audio> onpause
<video> onpause

onpause Attribute Value:

Value Description
script The script to be run on onpause

Sample Coding for onpause Attribute in HTML:

Tryit<!DOCTYPE html>
        <title>Wikitechy onpause attribute</title>
        <video width="320" height="240" controls onpause="onPause()">
            <source src="hibiscus.mp4" type="video/mp4">
            function onPause() 
              alert("Please press play button to resume");

Code Explanation for onpause Attribute in HTML:

onpause Attribute Code Explanation

  1. The onpause attribute is used to run the JavaScript function where the video is paused by the user.
  2. The <source> element is used to give the location of the video file.
  3. The function onPause() is called by the onpause attribute value. It is used to show an alert message when the video was paused.

Output for onpause Attribute in HTML:

onpause Attribute Output

  1. The output shows that the video player play the video.
  2. onpause Attribute Output
  3. If the video will pause or finished, then the alert message is display on the browser.

Browser Support for onpause Attribute in HTML:

Yes 9.0 Yes Yes Yes

Tips and Notes

  • The onplay attribute is used to define as a script can run the audio or video which will starts either or no longer paused.

Related Searches to onpause Attribute in html