vibrate_api_HTML5

HTML5 Vibration API for Mobile web development

While loading a web page, Using navigator.vibrate() you can make IPhone / Smart phone vibrate. You can use this feature for Alerting users in order to use some features on your page or website.

vibrate_api_HTML5
Vibrate Smart Phones Using HTML5

For example, Here the device will vibrate for 1000 ms then pause for 500 ms then again start vibrating for 1000 ms.

window.navigator.vibrate([1000, 500, 1000]);

It is not mandatory to provide a pause as above since the vibration automatically stops at the end of each vibration period. An array of values describes alternating periods of time in which the device is vibrating and not vibrating.

You can also cancel the existing vibration by passing Navigator.vibrate() with a value of 0.

Save the below HTML file and run on your mobile / tab.

<body>
   <script type="text/javascript">
      navigator.vibrate([1000, 500, 1000, 500, 1000, 500, 1000, 500, 1000, 500, 1000, 500, 1000, 500]);
   </script>
Just Vibrate, Run this page in a device which support vibration. For example Mobile phones (Smart Phones), Iphones, Tabs etc., It will not vibrate
</body>

As mentioned earlier run this page in a device which support vibration. For example Mobile phones, Tabs etc., It will not vibrate.

DEMO

Leave a Reply

Your email address will not be published. Required fields are marked *