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

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>
<html>
<head>
<title>Wikitechy onpause attribute</title>
</head>
<body>
<video width="320" height="240" controls onpause="onPause()">
<source src="hibiscus.mp4" type="video/mp4">
</video>
<script>
function onPause()
{
alert("Please press play button to resume");
}
</script>
</body>
</html>
Code Explanation for onpause Attribute in HTML:

- The onpause attribute is used to run the JavaScript function where the video is paused by the user.
- The <source> element is used to give the location of the video file.
- 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:

- The output shows that the video player play the video.
- 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.