How has fullscreen API evolved in recent JS versions?

Keywords: fullscreen API, JavaScript, web development, browser compatibility, user experience
Description: The fullscreen API allows web applications to present content in full-screen mode. It has evolved to include better browser compatibility, improved event handling, and more user-centric features, enhancing the way developers create immersive experiences.
            // Example of using the Fullscreen API in JavaScript
            function openFullscreen() {
                var elem = document.documentElement;
                if (elem.requestFullscreen) {
                    elem.requestFullscreen();
                } else if (elem.mozRequestFullScreen) { // Firefox
                    elem.mozRequestFullScreen();
                } else if (elem.webkitRequestFullscreen) { // Chrome, Safari and Opera
                    elem.webkitRequestFullscreen();
                } else if (elem.msRequestFullscreen) { // IE/Edge
                    elem.msRequestFullscreen();
                }
            }

            function closeFullscreen() {
                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();
                }
            }
        

Keywords: fullscreen API JavaScript web development browser compatibility user experience