Document.fullscreenEnabled - Web APIs 编辑
The read-only fullscreenEnabled
property on the Document
interface indicates whether or not full-screen mode is available. Full-screen mode is available only for a page that has no windowed plug-ins in any of its documents, and if all <iframe>
elements which contain the document have their allowfullscreen
attribute set.
Although this property is read-only, it will not throw if it is modified (even in strict mode); the setter is a no-operation and it will be ignored.
Syntax
var isFullscreenAvailable = document.fullscreenEnabled;
Value
A Boolean
value which is true
if the document and the elements within can be placed into full-screen mode by calling Element.requestFullscreen()
. If full-screen mode isn't available, this value is false
.
Example
In this example, before attempting to request full-screen mode for a <video>
element, the value of fullscreenEnabled
is checked, in order to avoid making the attempt when not available.
function requestFullScreen() {
if (document.fullscreenEnabled) {
videoElement.requestFullScreen();
} else {
console.log('Your browser cannot use fullscreen right now');
}
}
Specifications
Specification | Status | Comment |
---|---|---|
Fullscreen API The definition of 'Document.fullscreenEnabled' in that specification. | Living Standard | Initial definition |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论