...

View Full Version : Js delay function



vkonstanz
04-08-2003, 03:16 PM
I need a function in js that delay my page before loading for few seconds.
What's function do I need?

liorean
04-08-2003, 03:49 PM
There is no *synchronous* delay or wait functionality in javascript - but you could try to do something like this:
function fnDelay(iMs){ // iMs=[number TimeInMilliSeconds]
var
iStart=new Date;
while(new Date-iStart<iMs);
}And call that when you need the delay - but I wouldn't be surprised if you got a message that told you that execution of that script might slow the computer down. You usually get those when you try to do potentially nonterminal loops, or loops that will take too much time to execute.



There is of course the asynchronous setTimeout that you can use, but then your script execution will continue while waiting.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum