-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfullscreen.html
68 lines (61 loc) · 2.33 KB
/
fullscreen.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
<title></title>
<style>
* {
margin: 0;
padding: 0;
}
.border {
width: 300px;
height: 100px;
background-color: #eee;
}
</style>
</head>
<body>
<div class="border"></div>
<script src="filter-blur-stack.js"></script>
<script>
(function () {
(function () {
var runPrefixMethod = function ( element , method ) {
var usablePrefixMethod;
[ "webkit" , "moz" , "ms" , "o" , "" ].forEach( function ( prefix ) {
if ( usablePrefixMethod ) return;
if ( prefix === "" ) {
// 无前缀,方法首字母小写
method = method.slice( 0 , 1 ).toLowerCase() + method.slice( 1 );
}
var typePrefixMethod = typeof element[ prefix + method ];
if ( typePrefixMethod + "" !== "undefined" ) {
if ( typePrefixMethod === "function" ) {
usablePrefixMethod = element[ prefix + method ]();
} else {
usablePrefixMethod = element[ prefix + method ];
}
}
} );
return usablePrefixMethod;
};
if ( typeof window.screenX === "number" ) {
var eleFull = document.querySelector( ".border" );
eleFull.addEventListener( "click" , function () {
if ( runPrefixMethod( document , "FullScreen" ) || runPrefixMethod( document , "IsFullScreen" ) ) {
runPrefixMethod( document , "CancelFullScreen" );
this.title = this.title.replace( "退出" , "" );
} else if ( runPrefixMethod( this , "RequestFullScreen" ) ) {
this.title = this.title.replace( "点击" , "点击退出" );
}
} );
} else {
alert( "爷,现在是年轻人的时代,您就暂且休息去吧~~" );
}
})();
})();
</script>
</body>
</html>