HTML 参考手册
HTML 音频/视频 DOM preload 属性
页面一旦加载,就开始加载视频
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> </head> <body> <button onclick="enablePreload()" type="button">加载视频</button> <button onclick="disablePreload()" type="button">不加载视频</button> <button onclick="checkPreload()" type="button">检查加载状态</button> <br> <video id="video1" controls="controls"> <source src="/examples/mov_bbb.mp4" type="video/mp4"> <source src="/examples/mov_bbb.ogg" type="video/ogg"> 您的浏览器不支持 HTML5 video 标签。 </video> <script> myVid = document.getElementById("video1"); function enablePreload() { myVid.preload = "auto"; } function disablePreload() { myVid.preload = "none"; } function checkPreload() { alert(myVid.preload); } </script> <p>Video courtesy of <a href="http://www.bigbuckbunny.org/" target="_blank">Big Buck Bunny</a>.</p> </body> </html>
运行结果:
点击运行 »