在 HTML 中,当文件准备好开始播放时执行脚本?

htmlweb developmentfront end technology更新于 2024/8/14 12:28:17

您可以将 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>

相关文章


有用资源