-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbrowsersize.html
executable file
·44 lines (43 loc) · 2.48 KB
/
browsersize.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Browsersize</title>
<style>
table { width: 100%; border-spacing: 0; border-collapse: separate; }
tr:nth-child(odd) { background-color: #EEE; }
td.label { width: 10em; max-width: 25%; padding-right: 10px; }
</style>
</head>
<body>
<h1>Determine Browser Size for Responsive Design</h1>
<table>
<tr><td class="label">Browser window width:</td><td id="windowwidth">?</td></tr>
<tr><td class="label">Browser window height:</td><td id="windowheight">?</td></tr>
<tr><td class="label">Screen width:</td><td id="screenwidth">?</td></tr>
<tr><td class="label">Screen height:</td><td id="screenheight">?</td></tr>
<tr><td class="label">Device Pixel Ratio:</td><td id="pixelratio">?</td></tr>
<tr><td class="label">Screen color depth:</td><td id="colordepth">?</td></tr>
<tr><td class="label">User Agent:</td><td id="useragent">?</td></tr>
</table>
<script>
/*! GetDevicePixelRatio | Author: Tyson Matanich, 2012 | License: MIT */
(function(n){n.getDevicePixelRatio=function(){var t=1;return n.screen.systemXDPI!==undefined&&n.screen.logicalXDPI!==undefined&&n.screen.systemXDPI>n.screen.logicalXDPI?t=n.screen.systemXDPI/n.screen.logicalXDPI:n.devicePixelRatio!==undefined&&(t=n.devicePixelRatio),t}})(this);
/*! Determine Size for Responsive Design | License: NPL */
var $ = document.getElementById.bind(document);
var dimensions = {
width: window.innerWidth || document.documentElement.clientWidth || document.body.offsetWidth,
height: window.innerHeight || document.documentElement.clientHeight || document.body.offsetHeight
};
$("screenwidth").innerHTML = screen.width;
$("screenheight").innerHTML = screen.height;
$("colordepth").innerHTML = screen.colorDepth;
$("windowwidth").innerHTML = dimensions.width;
$("windowheight").innerHTML = dimensions.height;
$("pixelratio").innerHTML = window.getDevicePixelRatio();
$("useragent").innerHTML = navigator.userAgent;
</script>
</body>
</html>