运行 ❯
获取您的
自有
网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 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> /* Get the element you want displayed in fullscreen */ var elem = document.getElementById("myvideo"); /* Function to open fullscreen mode */ function openFullscreen() { if (elem.requestFullscreen) { elem.requestFullscreen(); } else if (elem.webkitRequestFullscreen) { /* Safari */ elem.webkitRequestFullscreen(); } else if (elem.msRequestFullscreen) { /* IE11 */ elem.msRequestFullscreen(); } } </script> </body> </html>