Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/469.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何进行js全屏切换_Javascript_Html - Fatal编程技术网

Javascript 如何进行js全屏切换

Javascript 如何进行js全屏切换,javascript,html,Javascript,Html,我想做一个按钮,将切换到全屏我的网站。我不知道该怎么做?看看一点点搜索带来了什么 利用搜索的力量 function toggleFullScreen() { if (!document.fullscreenElement) { document.documentElement.requestFullscreen(); } else { if (document.exitFullscreen) { document.exitFullscreen();

我想做一个按钮,将切换到全屏我的网站。我不知道该怎么做?

看看一点点搜索带来了什么


利用搜索的力量
function toggleFullScreen() {
  if (!document.fullscreenElement) {
      document.documentElement.requestFullscreen();
  } else {
    if (document.exitFullscreen) {
      document.exitFullscreen(); 
    }
  }
}