0
How to make a pause in JS code?
4 Answers
+ 1
I have the code to vibrate Morse. How can I program to wait for 300ms after vibration?
+ 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 >
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
0
function sleep(yourMiliseconds) {
var current = new Date().getTime();
while (current + yourMiliseconds>= new Date().getTime()) {
}
}
may be you can use like this.