<button onclick="fsManager.checkForFullscreen()">
         Enter fullscreen
      </button>
 class fullScreenManager {
            #isFullscreen = false;
            #docEl = document.documentElement;

            checkForFullscreen() {
               this.isFullscreen = !this.isFullscreen;

               if (this.isFullscreen) {
                  this.enterFullscreen();
               } else {
                  this.exitFullscreen();
               }
            }

            enterFullscreen() {
               this.#docEl.requestFullscreen() ||
                  this.#docEl.webkitRequestFullscreen() ||
                  this.#docEl.msRequestFullscreen();
            }
            exitFullscreen() {
               document.exitFullscreen() ||
                  document.webkitExitFullscreen() ||
                  document.msExitFullscreen();
            }
         }
         const fsManager = new fullScreenManager();

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.