Forum Moderators: open

Message Too Old, No Replies

need help making wait function

         

icpooreman

7:58 pm on Jul 1, 2005 (gmt 0)

10+ Year Member



Hey I'm new to the forum and am fairly new with javascript. Does JavaScript have a wait function? if not here's what I'm looking to do. I want to create my own fading effect here's what I need to do in psuedocode

for(i=100;i>0;i--){
set opacity of div=i
wait
}

I can't find a way for setInterval/Timeout to do it unless I'm willing to put myself in a loop and eat up CPU resources. This is all in a function that I don't want separated so I need to actually wait for this to complete to move on.

Does JavaScript have exact time functions like down to the millisecond that I could use to get the effect? Any help would be greatly appreciated.

j4mes

12:38 pm on Jul 3, 2005 (gmt 0)

10+ Year Member



function yourscript() {

// whatever the code to be delayed is

}

window.setTimeout('yourscript()', 5000);

Replace 500 with the delay time you want, in milliseconds.