JS 双击全屏显示和退出 -- requestFullScreen()

浏览器全屏实现方式

  1. 利用h5的requestFullScreen()实现
  2. 按esc退出全屏效果
// 如果想单击实现全屏的话,直接用@click点击事件
// do something...
mounted() {
   this.openFullscreen()
},
methods:{
  var elem = document.getElementById('fullscreen')
      if (elem.requestFullscreen) {
        elem.requestFullscreen()
      } else if (elem.mozRequestFullScreen) { /* Firefox */
        elem.mozRequestFullScreen()
      } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari & Opera */
        elem.webkitRequestFullscreen()
      } else if (elem.msRequestFullscreen) { /* IE/Edge */
        elem.msRequestFullscreen()
      }
    },
}

https://www.nhooo.com/jsref/elem_requestfullscreen.html

https://blog.csdn.net/weixin_33766168/article/details/91439341?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.no_search_link&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1.no_search_link

你可能感兴趣的:(JS 双击全屏显示和退出 -- requestFullScreen())