當 HTML 中載入媒體資料時執行指令碼?


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

更新於: 24-Jun-2020

113 次觀看

開啟職業生涯 生涯

完成本課程並獲得認證

開始使用
廣告
© . All rights reserved.