Vibration API

Control device vibration

BeginnerTopic: Browser API
Back

JavaScript Vibration API Program

This program helps you to learn the fundamental structure and syntax of JavaScript programming.

Try This Code
if ('vibrate' in navigator) {
    navigator.vibrate(200); // Vibrate for 200ms
}
Output
// Device vibrates

Understanding Vibration API

Vibration API controls device vibration.

Note: To write and run JavaScript programs, you need to set up the local environment on your computer. Refer to the complete article Setting up JavaScript Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your JavaScript programs.

Table of Contents