原生js实现浏览器全屏和退出全屏

全屏模式

//W3C
 if (docElm.requestFullscreen) {
      docElm.requestFullscreen();
}
 //FireFox
 else if (docElm.mozRequestFullScreen) {
      docElm.mozRequestFullScreen();
}
 //Chrome等
else if (docElm.webkitRequestFullScreen) {
      docElm.webkitRequestFullScreen();
}
//IE11
else if (docElm.msRequestFullscreen) {
      document.body.msRequestFullscreen();
}

 

退出全屏模式

if (document.exitFullscreen) {
   document.exitFullscreen();
}
else if (document.msExitFullscreen) {
    document.msExitFullscreen();
}
else if (document.mozCancelFullScreen) {
    document.mozCancelFullScreen();
}
else if (document.webkitCancelFullScreen) {
    document.webkitCancelFullScreen();
}else {
    window.parent.showTopBottom();
}

 

转载于:https://www.cnblogs.com/Mrrabbit/p/10795378.html

你可能感兴趣的:(原生js实现浏览器全屏和退出全屏)