📜  全屏角度示例 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:11.478000             🧑  作者: Mango

代码示例1
/**
   * Toggles the fullscreen mode.
   */
  toggleFullscreen() {
    if (document.webkitIsFullScreen) {
      this._exitFullscreen();
    } else {
      this._activateFullscreen();
    }
  }

  /**
   * Activate Full Screen Mode.
   */
  private _activateFullscreen() {
    let fullscreenElement = document.documentElement;
    if (fullscreenElement.requestFullscreen) {
      fullscreenElement.requestFullscreen();
    } else if (fullscreenElement.mozRequestFullScreen) { 
      /* Firefox */
      fullscreenElement.mozRequestFullScreen();
    } else if (fullscreenElement.webkitRequestFullscreen) { 
      /* Chrome, Safari and Opera */
      fullscreenElement.webkitRequestFullscreen();
    } else if (fullscreenElement.msRequestFullscreen) { 
      /* IE/Edge */
      fullscreenElement.msRequestFullscreen();
    }
  }

  /**
   * Exits Full Screen Mode.
   */
  private _exitFullscreen() {
    if (document.exitFullscreen) {
      document.exitFullscreen();
    } else if (document.mozCancelFullScreen) { 
      /* Firefox */
      document.mozCancelFullScreen();
    } else if (document.webkitExitFullscreen) { 
      /* Chrome, Safari and Opera */
      document.webkitExitFullscreen();
    } else if (document.msExitFullscreen) { 
      /* IE/Edge */
      document.msExitFullscreen();
    }
  }