js控制,监听 浏览器全屏

		
		//监听页面变化来监听按钮控制 浏览器全屏
            window.addEventListener("resize",function(){});
            
              //判断是否全屏
                if (document.body.scrollHeight === window.screen.height && document.body.scrollWidth === window.screen.width) {
                    // alert("全屏状态");
                    that.fullScreen=true
                }else{
                    that.fullScreen=false
                } 
           //控制浏览器是否全屏
            FullScreen() { 
                if(!document.fullscreenElement && // alternative standard method
                          !document.mozFullScreenElement && !document.webkitFullscreenElement) { // current working methods
                          
                    if(document.documentElement.requestFullscreen) {         
                        document.documentElement.requestFullscreen();      
                    } else if(document.documentElement.mozRequestFullScreen) {         
                        document.documentElement.mozRequestFullScreen();      
                    } else if(document.documentElement.webkitRequestFullscreen) {         
                        document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);      
                    }   
                } else {      
                    if(document.cancelFullScreen) {         
                        document.cancelFullScreen();      
                    } else if(document.mozCancelFullScreen) {         
                        document.mozCancelFullScreen();      
                    } else if(document.webkitCancelFullScreen) {         
                        document.webkitCancelFullScreen();      
                    }   
                }
            }

你可能感兴趣的:(js)