美文网首页个人收藏
js代码实现浏览器窗口全屏

js代码实现浏览器窗口全屏

作者: e0c52543163a | 来源:发表于2019-03-18 15:44 被阅读15次

js代码实现浏览器窗口全屏

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



//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/fearxe/article/details/80831209

相关文章

网友评论

    本文标题:js代码实现浏览器窗口全屏

    本文链接:https://www.haomeiwen.com/subject/waxbmqtx.html