运行 ❯
获取您
自己的
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <h2>Fullscreen with JavaScript</h2> <p>Click on the button to open the video in fullscreen mode.</p> <button onclick="openFullscreen();">Open Video in Fullscreen Mode</button> <p><strong>Tip:</strong> Press the "Esc" key to exit full screen.</p> <video width="100%" controls id="myvideo"> <source src="rain.mp4" type="video/mp4"> <source src="rain.ogg" type="video/ogg"> Your browser does not support the video tag. </video> <script> var elem = document.getElementById("myvideo"); function openFullscreen() { if (elem.requestFullscreen) { elem.requestFullscreen(); } else if (elem.webkitRequestFullscreen) { /* Safari */ elem.webkitRequestFullscreen(); } else if (elem.msRequestFullscreen) { /* IE11 */ elem.msRequestFullscreen(); } } </script> <p>Note: Internet Explorer 10 and earlier versions do not support the msRequestFullscreen() method.</p> </body> </html>