今天看到一个很有意思的API,可以用js操作浏览器进入全屏状态。requestFullscreen
document.querySelector('#fullscreen-button').addEventListener("click", function(e) {
toggleFullScreen();
}, false);
function toggleFullScreen() {
if (!document.fullscreenElement) {
document.documentElement.requestFullscreen();
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
}
}
}
【浏览器全屏API】在线体验