Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML Audio/Video DOM pause Event

HTML Audio/Video DOM pause Event

HTML audio/video Tag Reference HTML Audio/Video DOM Reference

Example

Display a message when the video is paused:

var vid = document.getElementById("myVideo");

vid.onpause = function() {

    alert("Video paused");

};

Try it »

The bottom of this article contains more examples.


Definition and Usage

The pause event is triggered when the audio/video is paused.

Tip: play The event is triggered when the audio/video starts playing (or resumes after being paused).


Browser support

The numbers in the table indicate the version number of the first browser to support the event.

Events
pause Yes 9.0 Yes Yes Yes

Syntax

In HTML:

<

audio|video

onpause="

myScript

">

Try it

In JavaScript:

audio|video

.onpause=function(){

myScript

};

Try it

In JavaScript, use the addEventListener() method:

audio|video

.addEventListener("pause",

myScript

);

Try it

Note: Internet Explorer 8 and earlier IE versions do not support addEventListener() method.


Technical Details

Supported HTML tags:
Supported JavaScript objects: Audio, Video

More examples

Example

Display a message when the audio is paused:

var aud = document.getElementById("myAudio");

aud.onpause = function() {

    alert("Audio paused");

};

Try it »


HTML audio/video Tag Reference HTML Audio/Video DOM Reference