简体   繁体   中英

How to detect shake in iphone browser?

There's questions about they're either old or don't give an answer. I'm not good at javascript, I'm alright at jQuery.

How would I do something when a shake is detected in the iphone browser? I'm planning on changing the url and sending the user back to the 'library' page of the website when a shake is detected.

From what I read, Android doesn't yet allow access to the accelerometer in the browser. Chrome for Android just came out last month though, and I'm not sure if it's supported in it yet, so I guess this question is just for the iPhone, and Android if anyone knows if it supports it yet. I'm assuming the same code would work for both.

如果您使用的是jquery,则可以使用我的js库https://github.com/GerManson/gShake

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM