Using javascript to make a mobile landing page vibrate the phone

0
2445

The following javascript uses the Vibrate API to make a phone vibrate when a page is loaded. You can time it with setTimeouts or onclick/onscroll if required.

<html>
<script>
navigator.vibrate = navigator.vibrate || navigator.webkitVibrate || navigator.mozVibrate || navigator.msVibrate;
navigator.vibrate(1000); // 1 second
</script>
Hello Buzz
</html>

There’s more information available at: http://www.sitepoint.com/use-html5-vibration-api/

This can be used to draw a users attention to the landing page or to create message effects etc.

vibrating phone

LEAVE A REPLY

Please enter your comment!
Please enter your name here