Discussion Locked

a delay or pause function in javascript

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I need a function like pause or delay to use in javascript in order to wait some seconds before calling another function withe the setTimeout function of javascript. Any help will be very welcome.

Best regards.

3 replies

by tjc

the below is a snipit of code that will pause the script for 5 seconds. Call it like any other function in javascipt.

// pause delay for 5 seconds
function pause() {
var now1= now2= diffrence = ' ';
now1 = new Date();
now2 = new Date();
while (diffrence < 5000) {
now2 = new Date();
diffrence = Date.parse(now2) - Date.parse(now1);
} //end while 5 second delay
}

by gsuruy

Thanks a lot for your valuable response, because of the everyday hurries i forto to say thanks.

Have a nice day.

gsuruy.

This discussion is closed to new replies.