0

How to make a pause in JS code?

7th Feb 2019, 11:40 AM
Erik Moučka
Erik Moučka - avatar
4 ответов
+ 1
I have the code to vibrate Morse. How can I program to wait for 300ms after vibration?
7th Feb 2019, 12:00 PM
Erik Moučka
Erik Moučka - avatar
+ 1
//it will vibrate and wait for 300ms and vibrate again <button onclick="vibrate()">Vibrate</button> <script> function vibrate(){ navigator.vibrate(1000); setTimeout(function(){ navigator.vibrate(1000); },300) } </script >
7th Feb 2019, 12:58 PM
Sudarshan Rai
Sudarshan Rai - avatar
0
if you want to debug your code. You can stop it with browser's tool. You can make steps: -->> right click on browser choose inspect -->> choose 'Sources' -->> select your row code -->>and action... You want to go step by step, you should press F11
7th Feb 2019, 11:50 AM
kaan
kaan - avatar
0
function sleep(yourMiliseconds) { var current = new Date().getTime(); while (current + yourMiliseconds>= new Date().getTime()) { } } may be you can use like this.
7th Feb 2019, 12:07 PM
kaan
kaan - avatar