JavaScript之实现全屏和退出全屏
2021-03-18 本文已影响0人
Cute_小肥鸡
1、JS的写法
//各种浏览器全屏模式的方法
function FullScreen(element){
if(element.requestFullscreen) {
element.requestFullscreen();
} else if(element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if(element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if(element.msRequestFullscreen) {
element.msRequestFullscreen();
}
}
//点击事件
$(document).off("click",".fullScreenDoc").on("click",".fullScreenDoc",function(e){
FullScreen(document.documentElement);
});