HTML onpause Event Attribute

Description

The event attribute onpause occurs when audio / video playback is paused either by the user or by software.

Syntax

<element onpause="script">

Values

  • scriptThe name of the script to use when the event has been triggered.

Example

<!DOCTYPE HTML>
<html>
<body>

<audio id="myAudio" controls onpause="myFunction()">  
  <source src="audio.mp3" type="audio/mpeg">
  Your browser does not support the audio tag.
</audio>

<p>Press play and then pause</p> 

<script>
function myFunction() {
    alert("audio file is paused.");
}
</script> 

<p>This example shows how to use the onpause attribute for an AUDIO element.</p>

</body>
</html>

Supported Tags

<audio> and <video>

Browser Support

Desktop
Explorer Edge Chrome Firefox Opera Safari
XXYes3.5XX
Tablets / Mobile
Android Chrome Firefox Opera Safari Samsung
YesYes4XXX