當檔案準備在 HTML 中開始播放時執行指令碼?


你可以對以下屬性使用 oncanplay 屬性:<audio>、<embed>、<object> 和 <video>。

示例

<!DOCTYPE HTML>
<html>
   <body>
      <video width = "300" height = "200" controls oncanplay = "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>
         alert("I am ready to begin.");
      </script>
   </body>
</html>

更新於: 2020-06-24

193 次檢視

開啟你的 職業生涯

透過完成課程獲得認證

開始吧
廣告
© . All rights reserved.