一行代码实现F11的功能,即让浏览器窗口全屏 - 一点点ning0_o - CSDN博客

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();
    }

原网址: 访问
创建于: 2018-10-13 20:36:31
目录: default
标签: 无

请先后发表评论
  • 最新评论
  • 总共0条评论