Press ESC to exit full screen mode

I have implemented full screen on my webapp desktop and pressing ESC will exit full screen and refresh my app layout as it calls my function, however when you press "Press ESC to exit full screen" exits full screen but does not update my layout as there is a direct browser API call. I'm trying to figure out how to click on "Press ESC to exit full screen" to call my function instead of the browser API. Thank.

+3


source to share


1 answer


I had the same problem, with this code I solved



$(document).on("webkitfullscreenchange mozfullscreenchange fullscreenchange", function () {
    if (!(document.mozFullScreen || document.webkitIsFullScreen || document.fullscreenchange)) {
        exit_fullscreen();
    }
});

function exit_fullscreen() {
[...] //whatever you need to change in layout
    if (document.exitFullscreen) {
        document.exitFullscreen();
    } else if (document.webkitExitFullscreen) {
        document.webkitExitFullscreen();
    } else if (document.mozCancelFullScreen) {
        document.mozCancelFullScreen();
    } else if (document.msExitFullscreen) {
        document.msExitFullscreen();
    }
}

      

0


source







All Articles