一. 全屏

function fullScreen() { var element = document.documentElement;
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
}
}

二. 退出全屏

function exitFullscreen() { if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
}
}

//监听window是否全屏,并进行相应的操作,支持esc键退出window.onresize = function() {
var isFull=!!(document.webkitIsFullScreen || document.mozFullScreen ||
document.msFullscreenElement || document.fullscreenElement
);//!document.webkitIsFullScreen都为true。因此用!!
if (isFull==false) {
$(“#exitFullScreen”).css(“display”,”none”);
$(“#fullScreen”).css(“display”,””);
}else{
$(“#exitFullScreen”).css(“display”,””);
$(“#fullScreen”).css(“display”,”none”);
}
}

三. 补充:
!和!!的区别
! 变量转换成boolean类型判断,null、undefined和空字符串取反都为false,其余都为true。
!! 用来做类型判断
if(a!=null&&typeof(a)!=undefined&&a!=’’){}
等价于if(!!a){}