
使用 onloaddata 事件在加载媒体数据时执行脚本。您可以尝试运行以下代码来实现 onloaddata 事件 -
示例
以下代码在视频加载时生成一个警报框 -
<!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>

