exit full screen code example
Example: event exit fullscreen
document.getElementById('fullscreen-div').addEventListener('fullscreenchange', (event) => {
if (document.fullscreenElement) {
console.log(`Element: ${document.fullscreenElement.id} entered fullscreen mode.`);
} else {
console.log('Leaving full-screen mode.');
}
});
document.getElementById('toggle-fullscreen').addEventListener('click', (event) => {
if (document.fullscreenElement) {
document.exitFullscreen();
} else {
document.getElementById('fullscreen-div').requestFullscreen();
}
});