zweizhao.github.io

项目,文章,随笔,博客,Markdown,个人网站,人生感悟。

View on GitHub
button#full-screen 全屏
button#exit-full 退出全屏
document.querySelector("#full-screen").addEventListener("click", fullScreen)

document.querySelector("#exit-full").addEventListener("click", exitFull)

function fullScreen() {
  var ele = document.documentElement
  var requestFullScreen = ele.requestFullScreen || // W3C
      ele.webkitRequestFullScreen || // Chrome
      ele.mozRequestFullScreen || // Firefox
      ele.msRequestFullScreen // IE11
  if(requestFullScreen) requestFullScreen.call(ele)
}

function exitFull() {
  var exitFullscreen = document.exitFullscreen || //W3C
      document.webkitExitFullscreen || // Chrome IE11
      document.mozCancelFullScreen // Firfox

  if(exitFullscreen) exitFullscreen.call(document)
}