Science Knowings: HTML Course For Social Media

HTML5 Vibration API

HTML5 Vibration API - Introduction

Welcome to the exciting world of the HTML5 Vibration API! This API allows you to make your web pages interactive and engaging by enabling you to control the vibration of the user's device. Let's dive right in and explore the amazing features of this API.

Checking Vibration Support

navigator.vibrate

Vibrate with Patterns

navigator.vibrate([100, 50, 100]);

vibrate() Method

The vibrate() method takes an array of time values as arguments. These values represent the durations of vibration and pauses in milliseconds. For example, [100, 50, 100] means vibrate for 100ms, pause for 50ms, and then vibrate again for 100ms.

Vibration Patterns

You can create various vibration patterns by adjusting the durations and the number of elements in the array. Experiment with different patterns to find what works best for your application.

pulsate() Method

navigator.vibrate([100]);

Stop Vibration

navigator.vibrate(0);

cancel() Method

The cancel() method stops any ongoing vibration, regardless of the pattern. This method is useful when you want to stop the vibration immediately.

Next Topic: HTML5 Full Screen API

why we need to learn HTML5 Full Screen API?

  • Advanced presentation control
  • Immersive browsing experience
  • Improved video playback quality
  • Enhanced gaming experience


  • Follow us to learn more about this exciting API!