-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
38 lines (33 loc) · 973 Bytes
/
test.html
File metadata and controls
38 lines (33 loc) · 973 Bytes
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="output">hello world</div>
<script type="text/javascript">
var divout = document.getElementById('output');
function show(message) {
divout.innerHTML = message;
}
function formatOrientation(o) {
var output = 'alpha: ' + o.alpha + '<br/>' + 'absolute: ' + o.absolute + '<br/>';
if (o.webkitCompassHeading)
{
output+= 'heading: ' + o.webkitCompassHeading + '<br/>';
} else {
output+= 'no webkit ' + '<br/>';
}
return output;
}
if ("ondeviceorientation" in window) {
window.addEventListener('deviceorientation', function (e) {
show(formatOrientation(e));
});
} else {
show('no event');
}
</script>
</body>
</html>