# Vibration API

# Single vibration

Vibrate the device for 100ms:

window.navigator.vibrate(100);

or

window.navigator.vibrate([100]);

# Check for support

Check if browser supports vibrations

if ('vibrate' in window.navigator)
    // browser has support for vibrations
else
    // no support

# Vibration patterns

An array of values describes periods of time in which the device is vibrating and not vibrating.

window.navigator.vibrate([200, 100, 200]);

# Syntax

  • let success = window.navigator.vibrate( pattern );

# Remarks

Support by browsers (opens new window) might be limited. Also support by the operating system may be limited.

The following table gives an overview of the earliest browser versions that provide support for vibrations.

Chrome Edge Firefox Internet Explorer Opera Opera Mini Safari
30 no support 16 no support 17 no support no support