Using the Device Orientation API demo on desktop Firefox 44 and Chrome Version 47.0.2526.80 m return different results for the coordinates.
Firefox returns null and Chrome 0. So far so good.
null
0
With this piece of code I am trying to check deviceorientation data.
deviceorientation
So first I check if the Device Orientation event is supported and both Firefox and Chrome say it is with the first alert firing.
if(window.DeviceOrientationEvent) { alert("Device Orientation Event is supported."); window.addEventListener('deviceorientation', function(event) { var alpha = event.alpha; var beta = event.beta; var gamma = event.gamma; // https://stackoverflow.com/a/27550756 if(alpha === null && typeof alpha === "object") alert(alpha); }, false); }
However only Chrome correctly returns the second alert as null whereas Firefox does not trigger the alert at all. But it should do so looking at the data results from the Device Orientation API demo.
I have also made sure to specifically check for null and not "", undefined, false, 0, or NaN as per How do I check for null values in JavaScript?
""
undefined
false
NaN
So how do I get Firefox to actually fire the second alert with the data of the deviceorientation ?
Related questions:
Device Orientation not working firefox
'deviceorientation' in Firefox?
Different gyroscope values in chrome mobile and safari mobile
Testing hardware support in Javascript for device orientation events of the iPhone 3GS
1.4m articles
1.4m replys
5 comments
57.0k users