HTML 5实现手机摇一摇的功能

if (window.DeviceMotionEvent) {
 window.addEventListener(‘devicemotion’,deviceMotionHandler, false);
}

编程技巧