Debian Codegraph @

test/viewport-meta.html

raw
1 <!doctype html>
2 <html>
3 <head>
4 <meta charset="utf-8"/>
5 <meta name="viewport" content="initial-scale=1.0" />
6 <title>Test: Responsive with ViewPort Tag</title>
7 </head>
8 <body>
9 <h2>Viewport Detections</h2>
10 <h5>&lt;meta name=&quot;viewport&quot; content=&quot;initial-scale=1.0&quot; /&gt;</h5>
11 <h3><a href="viewport.html">Without ViewPort Tag</a></h3>
12
13 <div id="result"></div>
14
15 <ul>
16 <li>1) Prefered: Inner browser surface/viewport. Excludes toolbars & scrollbars.</li>
17 <li>2) Fallback: Like 1, but not supported everywhere.</li>
18 <li>3) Experimental: Just testing accuracy here.</li>
19 <li>4) Prefered: Current browser size. Also takes into account a resized browser window.</li>
20 <li>5) Fallback: Measures the entire screen resolution.</li>
21 <li><a href="http://www.browserscope.org/user/tests/table/agt1YS1wcm9maWxlcnIRCxIEVGVzdBiAgICAiYLaCAw?v=3&layout=simple" target="results">BrowserScope Results</a></li>
22 </ul>
23
24
25
26 <script>
27 // Throttle navigators from triggering too many resize events
28 var resizeId = 0;
29 function onResize() {
30 clearTimeout(resizeId);
31 resizeId = setTimeout(resize, 50);
32 }
33
34 function addResult(title, value) {
35 var ele = document.createElement("div");
36
37 if (value !== false) {
38 ele.innerHTML = title + ": " + value;
39
40 if (value === "false") {
41 value = 0;
42 }
43 else if (value === "true") {
44 value = 1;
45 }
46
47 browserScopeAdd(title, value);
48 } else {
49 ele.innerHTML = title;
50 }
51
52 return ele;
53 }
54
55 // Log results to BrowserScope
56 function browserScopeClear() {
57 window._bTestResults = {};
58 }
59
60 function browserScopeAdd(title, value) {
61 window._bTestResults = window._bTestResults || {};
62 window._bTestResults[title] = value;
63 }
64
65 function browserScopeLog() {
66 var result = document.getElementById("browserscope");
67 if (result) {
68 result.parentNode.removeChild(result);
69 }
70
71 var apiKey = 'agt1YS1wcm9maWxlcnIRCxIEVGVzdBiAgICAiYLaCAw';
72 var script = document.createElement('script');
73
74 script.id = "browserscope";
75 script.src = 'http://www.browserscope.org/user/beacon/' + apiKey;
76
77 // use insertBefore to keep IE from throwing Operation Aborted (thx Bryan Forbes!)
78 var head = document.head || document.getElementsByTagName('head')[0];
79 // but insert at end of head, because otherwise if it is a stylesheet, it will not override values
80 head.insertBefore(script, head.lastChild);
81 }
82
83 // Detect
84 function resize() {
85 browserScopeClear();
86
87 var result = document.getElementById("result");
88 var parent = result.parentNode;
89 parent.removeChild(result);
90
91 var newResult = document.createElement("div");
92 newResult.id = "result";
93
94 newResult.appendChild(addResult("1) INNER measurements", false));
95
96 newResult.appendChild(addResult("innerWidth" , window.innerWidth));
97 newResult.appendChild(addResult("innerHeight", window.innerHeight));
98 newResult.appendChild(addResult("landscape (iwh)", (window.innerWidth > window.innerHeight).toString()));
99
100 newResult.appendChild(addResult("<br/>", false));
101 newResult.appendChild(addResult("2) INNER measurements", false));
102
103 newResult.appendChild(addResult("clientWidth" , document.documentElement.clientWidth));
104 newResult.appendChild(addResult("clientHeight", document.documentElement.clientHeight));
105 newResult.appendChild(addResult("landscape (cwh)", (document.documentElement.clientWidth > document.documentElement.clientHeight).toString()));
106
107 newResult.appendChild(addResult("<br/>", false));
108 newResult.appendChild(addResult("3) INNER measurements", false));
109
110 newResult.appendChild(addResult("availWidth", window.screen.availWidth));
111 newResult.appendChild(addResult("availHeight", window.screen.availHeight));
112 newResult.appendChild(addResult("landscape (awh)", (window.screen.availWidth > window.screen.availHeight).toString()));
113
114 newResult.appendChild(addResult("<br/>", false));
115 newResult.appendChild(addResult("4) OUTER measurements", false));
116
117 newResult.appendChild(addResult("outerWidth" , window.outerWidth));
118 newResult.appendChild(addResult("outerHeight", window.outerHeight));
119 newResult.appendChild(addResult("landscape (owh)", (window.outerWidth > window.outerHeight).toString()));
120
121 newResult.appendChild(addResult("<br/>", false));
122 newResult.appendChild(addResult("5) OUTER measurements", false));
123
124 newResult.appendChild(addResult("screen.width" , window.screen.width));
125 newResult.appendChild(addResult("screen.height", window.screen.height));
126 newResult.appendChild(addResult("landscape (swh)", (window.screen.width > window.screen.height).toString()));
127
128 parent.appendChild(newResult);
129 browserScopeLog();
130 }
131
132 resize();
133
134 // Manually attach, as to not overwrite existing handler
135 if (window.addEventListener) {
136 window.addEventListener("resize", onResize, false);
137
138 } else {
139 window.attachEvent("onresize", onResize);
140 }
141 </script>
142 </body>
143 </html>