JS开启浏览器全屏模式,需要手动触发

<html >
<meta charset="UTF-8">
<body>
<button onclick="launchFullscreen(document.documentElement);">启动全屏</button>  
<script>
function launchFullscreen(element) {
  if(element.requestFullscreen) {
    element.requestFullscreen();
  } else if(element.mozRequestFullScreen) {
    element.mozRequestFullScreen();
  } else if(element.webkitRequestFullscreen) {
    element.webkitRequestFullscreen();
  } else if(element.msRequestFullscreen) {
    element.msRequestFullscreen();
  }
}
</script>
</body>
</html>

 

posted @ 2017-07-03 11:00  God丶魔多  阅读(1485)  评论(0编辑  收藏  举报