Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to detect Iphone if shaken via javascript?

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()">
like image 843
CodeOverload Avatar asked Dec 10 '25 04:12

CodeOverload


1 Answers

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.

like image 68
notnoop Avatar answered Dec 12 '25 18:12

notnoop