JavaScript全屏/退出全屏方法(兼容谷歌、火狐、IE11)

function(){
   	/*判断是否全屏*/
   	var isFullscreen = document.fullScreenElement//W3C
			    	||document.msFullscreenElement //IE
			    	||document.mozFullScreenElement //火狐
			    	||document.webkitFullscreenElement //谷歌
			    	||false;
   	if(!isFullscreen){
	   	var el = document.documentElement;
   		if (el.requestFullscreen) { 
   			el.requestFullscreen(); 
	    } else if (el.mozRequestFullScreen) { 
	    	el.mozRequestFullScreen(); 
	    } else if (el.webkitRequestFullscreen) { 
	    	el.webkitRequestFullscreen(); 
	    } else if (el.msRequestFullscreen) { 
	    	el.msRequestFullscreen(); 
	    } 
   	}else{
   		if (document.exitFullscreen) { 
   			document.exitFullscreen(); 
	    } else if (document.msExitFullscreen) { 
	    	document.msExitFullscreen(); 
	    } else if (document.mozCancelFullScreen) { 
	    	document.mozCancelFullScreen(); 
	    } else if (document.webkitCancelFullScreen) { 
	    	document.webkitCancelFullScreen(); 
	    } 
   	}
}
展开阅读全文

没有更多推荐了,返回首页