在浏览器获取 HTML 媒体数据的过程中执行脚本?

htmlweb developmentfront end technology更新于 2025/8/18 2:52:17

使用 onprogress  属性,在浏览器获取 HTML 媒体数据的过程中执行脚本。

示例

您可以尝试运行以下代码来实现 onprogress  属性 −

<!DOCTYPE html>
<html>
   <body>
      <video id = "myVideo" width = "320" height = "176" controls onprogress = "display()">
         <source src = "/html5/foo.ogg" type = "video/ogg" />
         <source src = "/html5/foo.mp4" type = "video/mp4" />
         Your browser does not support HTML5 video.
      </video>
      <script>
         function display() {
            alert("Started");
         }
      </script>
   </body>
</html>

相关文章


有用资源