onvolumechange event
Examples
JavaScript is executed when the video volume changes:
<Video onvolumechange = "myFunction ()">
try it"
The bottom of the article contains more examples.
Definition and Usage
Onvolumechange event fires when the video / audio (audio / video) volume change.
This event can call the following ways:
- Increase or decrease the volume
- Media player to mute or un-mute
Tip: Use the Audio or Video object's volume property to set or return the video / audio (audio / video) volume.
Browser Support
Figures in the table represent the first browser to support this version of events.
event | |||||
---|---|---|---|---|---|
onvolumechange | Yes | 9.0 | Yes | Yes | Yes |
grammar
In HTML:
<Elementonvolumechange = "myScript"> try
In JavaScript:
object .onvolumechange = function () {myScript }; try
JavaScript, use the addEventListener () method:
object .addEventListener ( "volumechange", myScript ); try
Note: Internet Explorer 8 and earlier versions of IE do not support addEventListener () method.
technical details
Whether to support the bubble: | No |
---|---|
It can be canceled: | No |
Event Type: | Event |
Supported HTML tags: | <Audio>, <video> |
More examples
Examples
JavaScript is executed when the audio volume changes:
<Audio onvolumechange = "myFunction ()">
try it"
Examples
Set the volume using the volume attributes:
document.getElementById ( "myVideo") volume = 0.2.;
try it"
Event objects