event exit fullscreen

Solutions on MaxInterview for event exit fullscreen by the best coders in the world

showing results for - "event exit fullscreen"
Karl
27 Aug 2020
1document.getElementById('fullscreen-div').addEventListener('fullscreenchange', (event) => {
2  // document.fullscreenElement will point to the element that
3  // is in fullscreen mode if there is one. If not, the value
4  // of the property is null.
5  if (document.fullscreenElement) {
6    console.log(`Element: ${document.fullscreenElement.id} entered fullscreen mode.`);
7  } else {
8    console.log('Leaving full-screen mode.');
9  }
10});
11
12document.getElementById('toggle-fullscreen').addEventListener('click', (event) => {
13  if (document.fullscreenElement) {
14    // exitFullscreen is only available on the Document object.
15    document.exitFullscreen();
16  } else {
17    document.getElementById('fullscreen-div').requestFullscreen();
18  }
19});