明天看到一个很有意思的 API,能够用 js 操作浏览器进入全屏状态。
requestFullscreen
<button id="fullscreen-button">Enter Fullscreen</button>
document.querySelector('#fullscreen-button').addEventListener("click", function(e) {toggleFullScreen();
}, false);
function toggleFullScreen() {if (!document.fullscreenElement) {document.documentElement.requestFullscreen();
} else {if (document.exitFullscreen) {document.exitFullscreen();
}
}
}
在线体验