fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> </head> <body> <p>点击按钮创建 VIDEO 元素,一个 preload 设置为 "none", 另外一个 preload 设置为 "auto".</p> <button onclick="myFunction('none')">视频不预加载</button> <button onclick="myFunction('auto')">视频预加载</button> <br> <script> function myFunction(p){ var x = document.createElement("VIDEO"); x.setAttribute("controls", "controls"); var y = document.createElement("SOURCE"); y.setAttribute("src", "movie.mp4"); y.setAttribute("type", "video/mp4"); x.appendChild(y); var z = document.createElement("SOURCE"); z.setAttribute("src", "movie.ogg"); z.setAttribute("type", "video/ogg"); x.appendChild(z); // 设置 preload 属性: x.preload=p; document.body.appendChild(x); } </script> </body> </html>
运行结果