faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

6 of 8 people (75%) answered Yes
Recently 4 of 6 people (67%) answered Yes

Entry

Is there a window properties variable that will act in the same way as the setTimeout function?

Apr 4th, 2008 20:53
ha mo, Jean-Bernard Valentaten, Colin Fraser, wolfie Macantire,


> No, but if you do not want to use a set TimeOut() function, create 
> your own,
> Try 
>  for (i=0;i<10000;i++) ; // do nothing but waste processor time
But of course this is processor dependent (a 286 will take much longer 
than a Pentium 4), so you can alternatively pass the current time to a 
var and then check how much time has elapsed since.
Might look like this:
function delay(millis)
{
  var now = new Date();
  var mil = now.getTime();
  while (now.getTime() - mil <= millis) {;}
  return;
}
HTH
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com