编辑下面的代码:【加编码】
<html> <body> <video id="myVideo" controls src="movie.ogg"> 您的浏览器不支持 video 标签。 </video> <p>点击按钮修改视频的 URL。</p> <p id="demo"></p> <button onclick="myFunction()">点我</button> <script> var x = document.getElementById("myVideo"); function myFunction() { isSupp = x.canPlayType("video/mp4"); if (isSupp == "") { x.src = "mov_bbb.ogg"; } else { x.src = "mov_bbb.mp4"; } x.load(); document.getElementById("demo").innerHTML = "Video Courtesy of Big Buck Bunny - www.bigbuckbunny.org"; } </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂