Document:exitFullscreen() 方法
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Document
的 exitFullscreen()
方法请求将当前在全屏模式下呈现的文档元素退出全屏模式,恢复屏幕的先前状态。这通常会逆转先前调用 Element.requestFullscreen()
的效果。
语法
js
exitFullscreen()
参数
无。
返回值
示例
此示例使当前文档在鼠标按钮点击其内部时切换进出全屏显示模式。
js
document.onclick = (event) => {
if (document.fullscreenElement) {
document
.exitFullscreen()
.then(() => console.log("文档已退出全屏模式"))
.catch((err) => console.error(err));
} else {
document.documentElement.requestFullscreen();
}
};
备注:
有关更完整的示例,请参阅 Element.requestFullscreen()
示例。
规范
Specification |
---|
Fullscreen API # ref-for-dom-document-exitfullscreen① |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
exitFullscreen | ||||||||||||
Returns a Promise |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Partial support
- Partial support
- No support
- No support
- Uses a non-standard name.
- Requires a vendor prefix or different name for use.
- Has more compatibility info.
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.