I have an iPhone version of my website. Is it possible to detect, using JavaScript, when the iPhone is shaken? Something along the lines of:
<script> function shaken() { alert("you shaked !!!"); } < /script >
<body onshake="shaken()">
I have an iPhone version of my website. Is it possible to detect, using JavaScript, when the iPhone is shaken? Something along the lines of:
<script> function shaken() { alert("you shaked !!!"); } < /script >
<body onshake="shaken()">
No, only native apps can access whether it has been shaken or not.
You can implement a native app, by using a wrapper web view with PhoneGap (or other libraries). Such libraries expose motion events and such through a javascript interface.
Update: I mistakenly assumed that orientation doesn't get exposed through javascript. Thanks for the correction.
Check out PhoneGap and Appcelerator's Titanium. Both have JavaScript API's that provide access to things like this.
See my question here: Handle iPhone Events (like slide-left) in Mobile Web Site