|
|
Definition and Usage The onpause attribute defines a script to be run when the audio/video is paused either by the user or programmatically. Tip: The onplay attribute is used to define a script to run when the audio/video has been started or is no longer paused.
|
Play and pause the video.
<!DOCTYPE html>
<html>
<body>
<script>
function myFunction() { alert('The video has been paused');
}</script>
<p>
Play and pause the video.</p>
<video controls onpause="myFunction()">
<source src="https://download.samplelib.com/mp4/sample-5s.mp4" type="video/mp4">
<source src="https://download.samplelib.com/mp4/sample-5s.mp4" type="video/ogg">
Your browser does not support HTML5 video.</video>
<p>
Video courtesy of <a href="https://www.bigbuckbunny.org/" target="_blank">
Big Buck Bunny</a>
.</p>
</body>
</html>
The pause event occurs when the audio/video is paused either by the user or programmatically.
Tip: The play event occurs when the audio/video has been started or is no longer paused.
The numbers in the table specify the first browser version that fully supports the event.
<element onpause="script">
| Value | Description |
|---|---|
| script | The script to be run on pause |
| Supported HTML tags: | <audio> and <video> |
|---|
Play and pause the video.
<!DOCTYPE html>
<html>
<body>
<script>
function myFunction() {
alert('The video has been paused');
}
</script>
<p>Play and pause the video.</p>
<video controls onpause="myFunction()">
<source src="https://download.samplelib.com/mp4/sample-5s.mp4" type="video/mp4">
<source src="https://download.samplelib.com/mp4/sample-5s.mp4" type="video/ogg">
Your browser does not support HTML5 video.
</video>
<p>Video courtesy of <a href="https://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p>
</body>
</html>
Play and pause the audio.
<!DOCTYPE html>
<html>
<body>
<script>
function myFunction() {
alert('The audio has been paused');
}
</script>
<p>Play and pause the audio.</p>
<audio controls onpause="myFunction()">
<source src="https://file-examples.com/index.php/sample-audio-files/sample-mp3-download/" type="audio/ogg">
<source src="https://file-examples.com/index.php/sample-audio-files/sample-mp3-download/" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</body>
</html>
| html event attributes |
Type: | Develop |
Category: | Web Tutorial |
Sub Category: | HTML Media Events Attribute |
Uploaded by: | Admin |
Read Articlehttps://develop.horje.com/learn/1434/reference