共计 622 个字符,预计需要花费 2 分钟才能阅读完成。
js 实现 F11 全屏成果
提醒
该事件只能从用户操作的事件触发,因为全屏后看不到地址栏,很容易做成坑骗性质的钓鱼网站
-
关上全屏:
const docElm = document.documentElement; if (docElm.requestFullscreen) {docElm.requestFullscreen(); } else if (docElm.mozRequestFullScreen) {docElm.mozRequestFullScreen(); } else if (docElm.webkitRequestFullScreen) {docElm.webkitRequestFullScreen(); } else if (elem.msRequestFullscreen) {elem.msRequestFullscreen(); }
-
退出全屏:
if (document.exitFullscreen) {document.exitFullscreen(); } else if (document.mozCancelFullScreen) {document.mozCancelFullScreen(); } else if (document.webkitCancelFullScreen) {document.webkitCancelFullScreen(); } else if (document.msExitFullscreen) {document.msExitFullscreen(); }
正文完
发表至: javascript
2020-12-15