-
Notifications
You must be signed in to change notification settings - Fork 0
/
ttttt.html
40 lines (40 loc) · 1.32 KB
/
ttttt.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div style="margin:0 auto;height:600px;width:700px;">
<button id="btn">全屏</button>
<div id="content" style="margin:0 auto;height:500px;width:700px; background:#ccc;" >
<h1>全屏展示和退出全屏</h1>
</div>
</div>
</body>
</html>
<script>
document.getElementById("btn").onclick=function(){
var elem = document.getElementById("content");
requestFullScreen(elem);
/*
注意这里的样式的设置表示全屏显示之后的样式,
退出全屏后样式还在,
若要回到原来样式,需在退出全屏里把样式还原回去
(见写法三)
*/
elem.style.height = '800px';
elem.style.width = '1000px';
};
function requestFullScreen(element) {
var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen;
if (!requestMethod) {
requestMethod.call(element);
} else if (typeof window.ActiveXObject !== "undefined") {
var wscript = new ActiveXObject("WScript.Shell");
if (wscript !== null) {
wscript.SendKeys("{F1133}");
}
}
}
</script>