孙肖宁

HTML5中的全屏
HTML5规范允许用户自定义网页上任一元素全屏显示。 requestFullscreen() 开启全屏显示 can...
扫描右侧二维码阅读全文
12
2018/07

HTML5中的全屏

HTML5规范允许用户自定义网页上任一元素全屏显示。
requestFullscreen() 开启全屏显示
cancleFullscreen() 关闭全屏显示
不同浏览器需要添加前缀如:

 webkitRequestFullScreen、mozRequestFullScreen
 webkitCancleFullScreen、mozCancleFullScreen

通过document.fullScreen检测当前是否处于全屏
不同浏览器需要添加前缀
document.webkitIsFullScreen、document.mozFullScreen
全屏伪类

:full-screen .box {}、:-webkit-full-screen {}、:moz-full-screen {}
var docElm = document.documentElement;
    if (docElm.requestFullscreen) {
       docElm.requestFullscreen();
    }
    else if (docElm.mozRequestFullScreen) {
       docElm.mozRequestFullScreen();
    }
    else if (docElm.webkitRequestFullScreen) {
       docElm.webkitRequestFullScreen();
    }
Last modification:July 12th, 2018 at 03:25 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment