FullScreen API 全屏请求

2017-05-19  本文已影响0人  ANoman_M

[原文] : https://davidwalsh.name/fullscreen/

整个页面

launchFullScreen(document.documentElement);

某个元素

launchFullScreen(document.getElementById("videoElement"));

退出全屏:

调用退出全屏方法!
     exitFullscreen(); 
注意,exitFullscreen 只能通过document对象调用--而不是使用普通的DOM element.

Fullscreen属性与事件:

document.fullscreenElement : 当前处于全屏状态的元素element;
document.fullscreenEnabled: 标记fullscreen当前是否可用

当进入/退出全屏模式时,会触发fullscreenchange事件:

        var fullscreenElement = 
        document.fullscreenEnabled 
        || document.mozFullscreenElement 
        || document.webkitFullscreenElement; 
        var fullscreenEnabled = 
        document.fullscreenEnabled 
        || document.mozFullscreenEnabled 
        || document.webkitFullscreenEnabled; 
上一篇下一篇

猜你喜欢

热点阅读