Solving development problems  |  About this blog

Archive for the ‘wait function’ tag

Javascript Sleep or Wait function

This can be one possible implementation (not very clean, but working):

function sleep(numberMillis){
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true){
		now = new Date();
		if (now.getTime() > exitTime) return;
	}
};

Written by Avivo

July 29th, 2010 at 11:44 pm