llamatron
09-20-2003, 03:16 PM
I have the following piece of code that i need to execute twice. For various reasons i cant use for i = 1 to 10 :
for (i=0; i<5;i++){
setTimeout("newWindow2.location.href='http://www.myurl.com/myasp.asp",i*1000);
}
So i thought I would put it inside a while loop like this :
var j=0;
while(j < 2) {
for (i=0; i<5;i++){
setTimeout("newWindow2.location.href='http://www.myurl.com/myasp.asp",i*1000);
}
j++;
}
But the for part still only executes 5 times. Am I right in assuming that the code will continue executing the while loop before the for loop has even finished???
for (i=0; i<5;i++){
setTimeout("newWindow2.location.href='http://www.myurl.com/myasp.asp",i*1000);
}
So i thought I would put it inside a while loop like this :
var j=0;
while(j < 2) {
for (i=0; i<5;i++){
setTimeout("newWindow2.location.href='http://www.myurl.com/myasp.asp",i*1000);
}
j++;
}
But the for part still only executes 5 times. Am I right in assuming that the code will continue executing the while loop before the for loop has even finished???