js requestFullscreen实现全屏功能 浏览器兼容问题解决

设置全屏

谷歌:webkitRequestFullscreen()
火狐:mozRequestFullScreen()
IE    :msRequestFullscreen()

    var box=document.documentElement
	 if(box.requestFullscreen){
	     box.requestFullscreen()
	 }else if(box.webkitRequestFullscreen){
	     //谷歌浏览器
	     box.webkitRequestFullscreen()
	 }else if(box.mozRequestFullScreen){
	     //火狐浏览器
	     box.mozRequestFullScreen()
	 }else if(box.msRequestFullscreen){
	      //IE浏览器
	     box.msRequestFullscreen()
	 }else{
	     alert('你的浏览器太low了')
	 }
退出全屏
document.exitFullscreen()
判断全屏状态
if(document.fullscreenElement){
   alert('true')
   }else{
   alert('false')
 }

你可能感兴趣的:(web前端,js,javascript)