Vibration

The Vibration API allows Web applications to use the device's built-in vibration, if one is present.

API glimpse

navigator.vibrate(durationOrPattern)
Vibrate the device once for the duration given or according to durations pattern given.

Live Demo

  • function vibrateSimple() {
      navigator.vibrate(200);
    }
    
    function vibratePattern() {
      navigator.vibrate([100, 200, 200, 200, 500]);
    }
  • <button class="btn btn-default" onclick="vibrateSimple()">Vibrate for 200 ms</button>
    <button class="btn btn-default" onclick="vibratePattern()">Vibrate with pattern</button>

Resources