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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With