运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往空间
<!DOCTYPE html> <html> <body> <h1>HTML DOM Events</h1> <h2>The oncanplaythrough</h2> <p>Use the addEventListener() method to attach a "canplaythrough" event to a video element.</p> <video controls id="myVideo"> <source src="mov_bbb.mp4" type="video/mp4"> <source src="mov_bbb.ogg" type="video/ogg"> Your browser does not support HTML5 video. </video> <p>Video courtesy of <a href="https://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p> <p id="demo"></p> <script> document.getElementById("myVideo").addEventListener("canplaythrough", myFunction); function myFunction() { document.getElementById("demo").innerHTML = "Can play through without stopping."; } </script> </body> </html>