Skip to content Skip to sidebar Skip to footer

Vibrate API Not Working On Pageload

The following code isn't working... function onPageLoad(){ navigator.vibrate([500]);} Testing it on mobile device, when I attach to a button it works but not onload????

Solution 1:

IF you want to execute any javascript code you need to write it to javascript onload method

window.onload = function() {
  navigator.vibrate([500]);
};

or you can attach your function to body element onload event,

 <body onload="onPageLoad()">

Post a Comment for "Vibrate API Not Working On Pageload"