Movatterモバイル変換


[0]ホーム

URL:


  1. 面向开发者的 Web 技术
  2. Web API
  3. Document
  4. Document:FullScreenElement 属性

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in EnglishAlways switch to English

Document:FullScreenElement 属性

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Document.fullscreenElement 只读属性返回当前页面中以全屏模式呈现的Element,如果当前页面未使用全屏模式,则返回null

尽管这个属性是只读的,但如果修改它,即使在严格模式下也不会抛出错误;它的setter 方法是空操作将被忽略。

返回当前处于全屏模式的Element 对象;如果当前页面未使用全屏模式,则返回null。如果有多个元素处于全屏模式下,则返回最顶层(最近请求)的元素。

示例

这个示例展示了一个名为isVideoInFullscreen() 的函数,该函数查看fullscreenElement 返回的值;如果文档处于全屏模式(fullscreenElement 不为null)并且全屏元素的nodeNameVIDEO,表示为<video> 元素,则函数返回true,表示视频处于全屏模式。

js
function isVideoInFullscreen() {  if (document.fullscreenElement?.nodeName === "VIDEO") {    return true;  }  return false;}

规范

Specification
Fullscreen API
# ref-for-dom-document-fullscreenelement①

浏览器兼容性

参见

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2026 Movatter.jp