通过jquery监听div双击全屏再次双击恢复demo

$(".Box").on("dblclick", function(){
            var docId=$(this).attr("id");
            var height=document.getElementById(docId);
            var fullscreenElement =
                document.fullscreenElement ||
                document.mozFullScreenElement ||
                document.webkitFullscreenElement;
            
            console.log(fullscreenElement);
             if(docId&&fullscreenElement==null){
                launchIntoFullscreen(height);
            }else{
                exitFullscreen();
            }
        });
        
        
        
        //全屏显示
        function launchIntoFullscreen(element) {
            if(element.requestFullscreen){
                element.requestFullscreen();
            }
            else if(element.mozRequestFullScreen) {
                element.mozRequestFullScreen();
            }
            else if(element.webkitRequestFullscreen) {
                element.webkitRequestFullscreen();
            }
            else if(element.msRequestFullscreen) {
                element.msRequestFullscreen();
            }
        }
        
        //屏幕恢复
        function exitFullscreen() {
                if(document.exitFullscreen) {
                    document.exitFullscreen();
                } else if(document.mozCancelFullScreen) {
                    document.mozCancelFullScreen();
                } else if(document.webkitExitFullscreen) {
                    document.webkitExitFullscreen();
                }
            }
$(".Box").on("dblclick", function(){
            var docId=$(this).attr("id");
            var height=document.getElementById(docId);
            var fullscreenElement =
                document.fullscreenElement ||
                document.mozFullScreenElement ||
                document.webkitFullscreenElement;
            
            console.log(fullscreenElement);
             if(docId&&fullscreenElement==null){
                launchIntoFullscreen(height);
            }else{
                exitFullscreen();
            }
        });
        
        
        
        //全屏显示
        function launchIntoFullscreen(element) {
            if(element.requestFullscreen){
                element.requestFullscreen();
            }
            else if(element.mozRequestFullScreen) {
                element.mozRequestFullScreen();
            }
            else if(element.webkitRequestFullscreen) {
                element.webkitRequestFullscreen();
            }
            else if(element.msRequestFullscreen) {
                element.msRequestFullscreen();
            }
        }
        
        //屏幕恢复
        function exitFullscreen() {
                if(document.exitFullscreen) {
                    document.exitFullscreen();
                } else if(document.mozCancelFullScreen) {
                    document.mozCancelFullScreen();
                } else if(document.webkitExitFullscreen) {
                    document.webkitExitFullscreen();
                }
            }

通过jquery监听div双击全屏再次双击恢复demo

通过jquery监听div双击全屏再次双击恢复demo

上一篇:springcloud 的loadbalancer 轮询算法切换方法 2021.4.3


下一篇:JS经典挖坑题