Is there access to the iPhone accelerometer using Javascript?
صفحه اصلي

Is there access to the iPhone accelerometer using Javascript?

I'm starting to try and do some web based game programming for my iPhone, and other web enabled phones that my friends have, and was having a hard time finding information on accessing the accelerometer using Javascript in the browser.

With the latest release, I know I've got access to location information now but I was hoping that I could make use of the accelerometer for some of the games I plan on making.

Alternately, is this also possible with the Android phones?

How to build Apple's GCC on Linux/Windows?


Is if (variable) the same as if (variable != nil) in Objective-Ccross compiling c++ to iphone armiPhone use of mutexes with asynchronous URL requests


Cocoa-touch and UIButtonContent
iOS 4.2 provides Accelerometer & Gyroscope support through the DeviceOrientation API.. Why doesn't an iPhone app's main() function ever get a chance to finish? Here a working javascript snippet..


If your are using iOS 4.2 or more, then you must did it:


jharlap is correct, however I'd be curious to know if this would job on the Palm Pre. Native development on the Pre is done using html and JavaScript, however there are special JavaScript APIs to access the phone's features this I believe only job for locally stored apps. I wonder if these are available through the browser. I doubt it, although it would be interesting..


Checkout PhoneGap project. It provides API to access the accelerometer and the GPS location from javascript.. "Regular" javascript cannot access the accelerometer info, it must access the geolocation using the W3C geolocation API supported by iPhone OS 3.0.. Yet, a project (e.g. PhoneGap) must be used to build a bridge between javascript and Objective-C capabilities to expose this functionality. This works if you want to deploy the app as a standalone application, this simply has one WebKit which loads the html content from the server.. I haven't played with their framework, although they provide templates for the iPhone and Android projects and you must job on developing your javascript game which would job almost-out-of-the-box on iPhone and Android. I cannot comment on the performance and the user experience though..

58 out of 100 based on 43 user ratings 318 reviews