检测手机上的全屏模式

问题描述 投票:1回答:1

我花了很多时间去搜索检测手机上的全屏模式。 但我发现的结果是只适用于桌面浏览器。下面是 检测全屏模式

有什么方法可以检测手机上的全屏模式吗?

javascript fullscreen html5-fullscreen
1个回答
0
投票

查看 document.fullscreenElement 属性。

https:/developer.mozilla.orgen-USdocsWebAPIDocumentOrShadowRootfullscreenElement。

这个例子介绍了一个函数isVideoInFullscreen(),该函数查看fullscreenElement返回的值;如果文档处于全屏模式(fullscreenElement不是null),且全屏元素的nodeName是VIDEO,表示是一个元素,则该函数返回true,表示视频处于全屏模式。

function isVideoInFullscreen() {
  if (document.fullscreenElement && document.fullscreenElement.nodeName == 'VIDEO') {
    return true;
  }
  return false;
}
© www.soinside.com 2019 - 2024. All rights reserved.