Execute a JavaScript when the volume of a video has been changed:
More "Try it Yourself" examples below.
The onvolumechange event occurs each time the volume of a video/audio has been changed.
This event is invoked by:
Tip: Use the volume property of the Audio/Video Object to set or return the audio volume of an audio/video.
The numbers in the table specify the first browser version that fully supports the event.
Event | |||||
---|---|---|---|---|---|
onvolumechange | Yes | 9.0 | Yes | Yes | Yes |
In HTML:
In JavaScript:
In JavaScript, using the addEventListener() method:
Note: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.
Bubbles: | No |
---|---|
Cancelable: | No |
Event type: | Event |
Supported HTML tags: | <audio> and <video> |
DOM Version: | Level 3 Events |
Execute a JavaScript when the volume of an audio has been changed:
Using the volume property to set the volume: