今天看到一個很有意思的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();
}
}
}