PHP前端开发

当浏览器正在获取HTML中的媒体数据时,执行一个脚本?

百变鹏仔 4周前 (09-22) #HTML
文章标签 脚本

使用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>