- Instant help with your JavaScript coding problems

Play video in fullscreen with vanilla JavaScript

Question:
How to play video in fullscreen with vanilla JavaScript?
Answer:
const vid = document.getElementById('video-id');
vid.requestFullscreen();
Description:

If you want to allow site visitors to watch a video on your site in full-screen mode you can simply achieve this by calling the requestFullscreen method on the video element.

The requestFullscreen() method asks the user agent to place the specified element into full-screen mode, removing all of the browser's UI elements as well as all other applications from the screen. Returns a Promise which is resolved once full-screen mode has been activated.

Share "How to play video in fullscreen with vanilla JavaScript?"