Document.querySelector()
and Element.requestFullscreen()
to open the given element in fullscreen.Document.exitFullscreen()
to exit fullscreen mode.el
, to use body
as the default element.mode
, to open the element in fullscreen mode by default.const fullscreen = (mode = true, el = 'body') =>
mode
? document.querySelector(el).requestFullscreen()
: document.exitFullscreen();
fullscreen(); // Opens `body` in fullscreen mode
fullscreen(false); // Exits fullscreen mode
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️