-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdevice-test.html
111 lines (106 loc) · 2.86 KB
/
device-test.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- settings -->
<meta name="apple-mobile-web-app-capable" content="no">
<meta name="mobile-web-app-capable" content="no">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0">
<title>Device test</title>
<meta name="application-name" content="Device test"/>
<meta name="apple-mobile-web-app-title" content="Device test">
<meta name="description" content="Test certain properties of your device.">
<meta name="theme-color" content="#000">
<link rel="icon" sizes="192x192" href="img/icon.png">
<link rel="apple-touch-icon" href="img/icon.png">
<meta property="og:image" content="img/icon.png"/>
<!-- imports -->
<script type="text/javascript" src="js/jquery-3.1.1.min.js" charset="UTF-8"></script>
<style>
html,
body {
padding: 0px;
margin: 0px;
width: 100%;
height: 100%;
font-size: 18px;
font-family: sans-serif;
}
#viewport-test {
position: relative;
background: #fff;
padding: 0px;
margin: 0px;
width: 100%;
height: 100%;
}
#inner-box {
position: absolute;
background: #000;
color: #fff;
top: 10px;
left: 10px;
width: calc(100% - 20px);
height: calc(100% - 20px);
display: flex;
flex-direction: column;
justify-content: center;
align-content: center;
align-items: center;
overflow: auto;
}
#info-box {
border: 1px solid white;
padding: 10px;
}
</style>
</head>
<body>
<div id="viewport-test">
<div id="inner-box">
<p>Window and viewport data:</p>
<div id="info-box"></div>
<p>Test influence of mobile keyboard:</p>
<input placeholder="">
<p>Test fullscreen:</p>
<button onclick="enterFullscreen()">Fullscreen</button>
</div>
</div>
</body>
<script>
$(document).ready(function(){
//on resize
$(window).resize(function() {
showWindowSizeData();
});
//init
showWindowSizeData();
});
//Window and viewport sizes
function showWindowSizeData(){
$('#info-box').html(''
+ 'Window width: ' + $(window).width() //Returns width of browser viewport
+ '<br>Window height: ' + $(window).height()
+ '<br>Document width: ' + $(document).width() //Returns width of HTML document
+ '<br>Document height: ' + $(document).height()
+ '<br>Box width: ' + $('#viewport-test').width() //Returns width of test box
+ '<br>Box height: ' + $('#viewport-test').height()
);
}
//Switch to fullscreen
function enterFullscreen(element){
if (!element){
element = document.documentElement;
}
if(element.requestFullscreen){
element.requestFullscreen();
}else if(element.mozRequestFullScreen){
element.mozRequestFullScreen();
}else if(element.msRequestFullscreen){
element.msRequestFullscreen();
}else if(element.webkitRequestFullscreen){
element.webkitRequestFullscreen();
}
}
</script>
</html>