Web Vibration API Experiment

I was browsing on the Web when suddenly an advertisement showed up and vibrate my phone. I was confused for a second because it said that there is a virus inside my phone. Knowing that it is an advertisement, I ignored that. But, I did not know that you can vibrate your device from Web!

This was created to demonstrate Web Vibration API. It consists of a function, navigator.vibrate(), to do vibration for some amount of time.

Since the API only allows to vibrate for a finite amount of time, a timer is scheduled to re-vibrate the device (using setTimeout() function). To prevent gap between vibration, the length of each vibration is doubled. It is fine because the vibrate() function will reset the duration.

Try different vibration cycle

open in new window