Document.onfullscreenchange

Document接口的onfullscreenchange 属性是 fullscreenchange 事件的处理器,该处理器在文档进入或者退出全屏模式的时候立即触发。

语法

targetDocument.onfullscreenchange = fullscreenChangeHandler;

Value

每当文档接收到fullscreenchange 事件时都会调用该事件处理程序,它表明文档正在进入或退出全屏模式。

使用说明

fullscreenchange事件不会直接说明文档当前是进入还是退出全屏模式,因此你的事件处理程序应查看Document.fullscreenElement的值。 如果为null,则该事件表示已退出全屏模式; 否则,指定的元素将接管屏幕。

示例

document.onfullscreenchange = function ( event ) { 
  console.log("FULL SCREEN CHANGE")
}; 
document.documentElement.onclick = function () {
  // requestFullscreen() 方法必须在一个事件处理器的方法体里执行,否则将会失败
  document.documentElement.requestFullscreen();
}

规范

Specification Status Comment
Fullscreen API
onfullscreenchange
Living Standard Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
onfullscreenchangeChrome Full support 71
Full support 71
Full support 45
Alternate Name
Alternate Name Uses the non-standard name: onwebkitfullscreenchange
Edge Full support 12Firefox Full support 64
Full support 64
No support 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.
No support 10 — 65
Alternate Name
Alternate Name Uses the non-standard name: onmozfullscreenchange
IE Full support 11
Alternate Name
Full support 11
Alternate Name
Alternate Name Uses the non-standard name: onmsfullscreenchange
Opera Full support YesSafari Full support 5.1
Alternate Name
Full support 5.1
Alternate Name
Alternate Name Uses the non-standard name: onwebkitfullscreenchange
WebView Android Full support 71
Full support 71
Full support 45
Alternate Name
Alternate Name Uses the non-standard name: onwebkitfullscreenchange
Chrome Android Full support 71
Full support 71
Full support 45
Alternate Name
Alternate Name Uses the non-standard name: onwebkitfullscreenchange
Firefox Android Full support 64
Full support 64
No support 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.
No support 10 — 65
Alternate Name
Alternate Name Uses the non-standard name: onmozfullscreenchange
Opera Android Full support YesSafari iOS Full support 5.1
Alternate Name
Full support 5.1
Alternate Name
Alternate Name Uses the non-standard name: onwebkitfullscreenchange
Samsung Internet Android Full support 5.0

Legend

Full support  
Full support
User must explicitly enable this feature.
User must explicitly enable this feature.
Uses a non-standard name.
Uses a non-standard name.

相关文章