Sử dụng sự kiện onloaddata để thực thi tập lệnh khi dữ liệu phương tiện được tải. Bạn có thể thử chạy đoạn mã sau để triển khai sự kiện onloaddata -
Ví dụ
Mã sau tạo hộp cảnh báo khi video được tải -
<!DOCTYPE html>
<html>
<body>
<video controls onloadeddata = "display()">
<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 display() {
alert("Loaded!");
}
</script>
</body>
</html>