1. 程式人生 > >js程式碼實現瀏覽器視窗全屏

js程式碼實現瀏覽器視窗全屏

1、全屏

//全屏
    var docElm = document.documentElement;
    //W3C
    if(docElm.requestFullscreen) {
      docElm.requestFullscreen();
    }

    //FireFox
    else if(docElm.mozRequestFullScreen) {
      docElm.mozRequestFullScreen();
    }

    //Chrome等
    else if(docElm.webkitRequestFullScreen) {
      docElm.webkitRequestFullScreen();
    }

    //IE11
else if(elem.msRequestFullscreen) { elem.msRequestFullscreen(); }

2、退出全屏

    //W3C
    if (document.exitFullscreen) {
      document.exitFullscreen();
    }
    //FireFox
    else if (document.mozCancelFullScreen) {
      document.mozCancelFullScreen();
    }
    //Chrome等
    else if (document
.webkitCancelFullScreen) { document.webkitCancelFullScreen(); } //IE11 else if (document.msExitFullscreen) { document.msExitFullscreen(); }
轉自:https://blog.csdn.net/ning0_o/article/details/69566590