Thuộc tính sự kiện ontimeupdate kích hoạt khi vị trí phát của media (ví dụ video) thay đổi. Có thể là tua nhanh hoặc tua lùi trong video hoặc audio.
Ví dụ
Bạn có thể chạy mã sau để triển khai thuộc tính ontimeupdate:
<!DOCTYPE html>
<html>
<body>
<h2 id="test">Phát</h2>
<video id="myid" width="320" height="176" controls ontimeupdate="myFunction()">
<source src="/html5/foo.ogg" type="video/ogg" />
<source src="/html5/foo.mp4" type="video/mp4" />
Trình duyệt của bạn không hỗ trợ phần tử video.
</video>
<script>
function myFunction() {
document.getElementById("test").innerHTML = "Vị trí hiện tại: " + document.getElementById("myid").currentTime;
}
</script>
</body>
</html>