accessing iPhone compass with JavaScript

Drew Dara-Abrams picture Drew Dara-Abrams · Apr 2, 2010 · Viewed 7.7k times · Source

Know if it's possible to access the iPhone compass in Safari using JavaScript? I see how the GPS can be accessed, but I can't figure out the compass.

Answer

christo16 picture christo16 · Apr 2, 2010

You cannot access that information via javascript, unless you're using something like iPhoneGap

At the time this was true, in iOS 5 you can use the compass heading in JS. https://developer.apple.com/documentation/webkitjs/deviceorientationevent/1804777-webkitcompassheading