Vibration API
Single vibration
Section titled “Single vibration”Vibrate the device for 100ms:
window.navigator.vibrate(100);or
window.navigator.vibrate([100]);Check for support
Section titled “Check for support”Check if browser supports vibrations
if ('vibrate' in window.navigator) // browser has support for vibrationselse // no supportVibration patterns
Section titled “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
Section titled “Syntax”- let success = window.navigator.vibrate( pattern );
Remarks
Section titled “Remarks”Support by browsers 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