Menu

gitpiper

fullscreen javascript Code Snippet in 2024

browserintermediate

Last Updated: 3 November 2024

Opens or closes an element in fullscreen mode.

  • Use Document.querySelector() and Element.requestFullscreen() to open the given element in fullscreen.
  • Use Document.exitFullscreen() to exit fullscreen mode.
  • Omit the second argument, el, to use body as the default element.
  • Omit the first 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

javascript snippet similar to fullscreen For You in November 2024

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️

© 2024 GitPiper. All rights reserved

Rackpiper Technology Inc

Company

About UsBlogContact

Subscribe to our Newsletter

Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️