The onvolumechange ทริกเกอร์แอตทริบิวต์เมื่อผู้ใช้เปลี่ยนระดับเสียงของวิดีโอหรือเสียงที่เข้าถึงบนหน้าเว็บ การเปลี่ยนแปลงนี้สามารถเพิ่มระดับเสียง ลดระดับเสียง ปิดเสียง ฯลฯ
ตัวอย่าง
คุณสามารถลองเรียกใช้โค้ดต่อไปนี้เพื่อใช้งาน onvolumechange แอตทริบิวต์ −
<!DOCTYPE html>
<html>
<body>
<h2 id="test">Play</h2>
<video id = "myid" width = "320" height = "176" controls onvolumechange = "myFunction()">
<source src = "/html5/foo.ogg" type = "video/ogg" />
<source src = "/html5/foo.mp4" type = "video/mp4" />
Your browser does not support the video element.
</video>
<script>
function myFunction() {
document.getElementById("test").innerHTML = "Volume changed";
}
</script>
</body>
</html>