DocumentOrShadowRoot.fullscreenElement read-only property returns the 元素 that is currently being presented in full-screen mode in this document, or null if full-screen mode is not currently in use.

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.

句法

var element = document.fullscreenElement;
					

返回值

元素 object that's currently in full-screen mode; if full-screen mode isn't currently in use by the document >, the returned value is null .

范例

This example presents a function, isVideoInFullscreen() , which looks at the value returned by fullscreenElement ; if the document is in full-screen mode ( fullscreenElement isn't null ) and the full-screen element's nodeName is VIDEO , indicating a <video> element, the function returns true , indicating that the video is in full-screen mode.

function isVideoInFullscreen() {
  if (document.fullscreenElement && document.fullscreenElement.nodeName == 'VIDEO') {
    return true;
  }
  return false;
}
					

规范

规范 状态 注释
全屏 API
The definition of 'Document.fullscreenElement' in that specification.
实时标准 初始定义

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
fullscreenElement Chrome 53 Prefixed
53 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge ≤18 Prefixed
≤18 Prefixed
Prefixed Implemented with the vendor prefix: webkit
12 Prefixed
Prefixed Implemented with the vendor prefix: ms
Firefox 64
64
不支持 47 — 65 Disabled
Disabled From version 47 until version 65 (exclusive): this feature is behind the full-screen-api.unprefix.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
不支持 9 — 65 Alternate Name
Alternate Name Uses the non-standard name: mozFullScreenElement
IE Yes Prefixed
Yes Prefixed
Prefixed Implemented with the vendor prefix: ms
Opera 40 Prefixed
40 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari Yes Prefixed
Yes Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android 53 Prefixed
53 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Chrome Android 53 Prefixed
53 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 64
64
不支持 47 — 65 Disabled
Disabled From version 47 until version 65 (exclusive): this feature is behind the full-screen-api.unprefix.enabled preference (needs to be set to true ). To change preferences in Firefox, visit about:config.
不支持 9 — 65 Alternate Name
Alternate Name Uses the non-standard name: mozFullScreenElement
Opera Android 41 Prefixed
41 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari iOS 部分支持 12 Alternate Name
部分支持 12 Alternate Name
Full-screen mode is only supported on the iPad.
Alternate Name Uses the non-standard name: webkitFullscreenElement
Samsung Internet Android 6.0 Prefixed
6.0 Prefixed
Prefixed Implemented with the vendor prefix: webkit

图例

完整支持

完整支持

部分支持

部分支持

见实现注意事项。

用户必须明确启用此特征。

用户必须明确启用此特征。

使用非标名称。

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

另请参阅

元数据

  • 最后修改: