JavaScript中的document.exitFullscreen


本文作者: jsweibo

本文链接: https://jsweibo.github.io/2019/11/15/JavaScript%E4%B8%AD%E7%9A%84document-exitFullscreen/

摘要

本文主要讲述了:

  1. 返回值类型
  2. 作用

正文

返回值类型

Promise

作用

退出全屏显示状态

示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
</head>
<body>
<button id="foo" type="button">Fullscreen Display</button>
<script>
const foo = document.querySelector('#foo');

foo.addEventListener('click', function () {
if (document.fullscreenElement === null) {
this.requestFullscreen();
} else {
document.exitFullscreen();
}
});
</script>
</body>
</html>

参考资料

本文作者: jsweibo

本文链接: https://jsweibo.github.io/2019/11/15/JavaScript%E4%B8%AD%E7%9A%84document-exitFullscreen/


本文对你有帮助?请支持我


支付宝
微信