Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2002
    Location
    WI - is not only cows and beer
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Making loop to stop for a while

    Hi!
    Is it possible to make loop wait on each step?

    I tried to use setTimeout - its not working
    I tried to use break - its let me do loop only once, than I made it nested loop - no visible pause

    Please, I just dont wanna give up.
    "Intelegence complicates.
    Wisdom simplifies."
    Mason Cooley

  • #2
    New Coder
    Join Date
    Jun 2002
    Location
    WI - is not only cows and beer
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    for (condition)
    {
    document.write(Something)
    /*I want it make stop here*/
    }


    Thank you
    "Intelegence complicates.
    Wisdom simplifies."
    Mason Cooley

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    338
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    var interval=setInterval(writeStuff,1500);
    var i=0;
    var thingsToWrite=["hello","how are you?","fine","you?","fine","good","bye"]; //it's a time like this I wish there was the qw "thingy" in JS!
    
    function writeStuff() {
    document.writeln(thingsToWrite[i]+"<br/>");
    i++;
    if(i==thingsToWrite.length) 
    clearInterval(interval);
    }
    Hope that helps!

    Happy coding!

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Delaware, USA
    Posts
    138
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This gives a pretty good explanation.


    http://www.faqts.com/knowledge_base/...d/1602/fid/143

  • #5
    New Coder
    Join Date
    Jun 2002
    Location
    WI - is not only cows and beer
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up Thank you

    It works now, but only at IE
    not NS, but I will do something about it

    You can take a look at this "stop" here:
    http://fatweb.info
    "Intelegence complicates.
    Wisdom simplifies."
    Mason Cooley


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •