--- title: document.mozFullScreenEnabled slug: Web/API/Document/fullscreenEnabled translation_of: Web/API/Document/fullscreenEnabled original_slug: Web/API/Document/mozFullScreenEnabled ---

{{ ApiRef() }}

概述

返回一个布尔值,表明浏览器是否支持全屏模式. 全屏模式只在那些不包含窗口化的插件的页面中可用.对于一个{{ HTMLElement("iframe") }}元素中的页面,则它必需拥有{{ HTMLAttrXRef("mozallowfullscreen", "iframe") }}属性.

语法

var isFullScreenAvailable = document.mozFullScreenEnabled;

如果当前文档可以进入全屏模式,则isFullScreenAvailabletrue

例子

function requestFullScreen() {
  if (document.mozFullScreenEnabled) {
    videoElement.requestFullScreen();
  } else {
    console.log('你的浏览器不支持全屏模式!');
  }
}

备注

进入页面使用全屏模式查看详情和示例.

浏览器兼容性

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatUnknown() }} {{ CompatGeckoDesktop("10.0") }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatGeckoMobile("10.0") }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

规范

该方法在规范草案 http://dvcs.w3.org/hg/fullscrezh-cn/raw-file/tip/Overview.html#dom-document-fullscreenenabled 中被提出.

相关链接

{{ languages( { "en": "en/DOM/document.mozFullScreenEnabled" } ) }}