HTML onvolumechange Event Attribute
Example
Alert that the volume of a video has been changed:
<script>
function myFunction() {
alert('The volume has been changed');
}
</script>
<video onvolumechange="myFunction()">
Try it Yourself »
More "Try it Yourself" examples below.
Definition and Usage
The volumechange event occurs each time the volume of a video/audio has been changed.
This event is invoked by:
- Increasing or decreasing the volume
- Muting or unmuting the media player
Tip: Use the volume property of the Audio/Video Object to set or return the audio volume of an audio/video.
Browser Support
The numbers in the table specify the first browser version that fully supports the event.
Event | |||||
---|---|---|---|---|---|
volumechange | Yes | 9.0 | Yes | Yes | Yes |
Syntax
<element onvolumechange="script">
Attribute Values
Value | Description |
---|---|
script | The script to be run at volume change |
Technical Details
Supported HTML tags: | <audio> and <video> |
---|
More Examples
Example
Alert that the volume of an audio file has been change:
<script>
function myFunction() {
alert('The volume has been changed');
}
</script>
<audio onvolumechange="myFunction()">
Try it Yourself »