Javascript: Fullscreen

To enter fullscreen mode:

document.documentElement.requestFullscreen();

To exit fullscreen mode:

document.exitFullscreen();

Toggling fullscreen mode:

<script>
  function toggleFullScreen() {
    if (!document.fullscreenElement) {
      document.documentElement.requestFullscreen();
    } else if (document.exitFullscreen) {
      document.exitFullscreen();
    }
  }
</script>

<button onclick=toggleFullScreen()>Toggle Fullscreen</button>

References:


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *