Web Analytics Made Easy -
StatCounter Making loop to stop for a while - CodingForum

Announcement

Collapse
No announcement yet.

Making loop to stop for a while

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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
    for (condition)
    {
    document.write(Something)
    /*I want it make stop here*/
    }


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

    Comment


    • #3
      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!

      Comment


      • #4
        This gives a pretty good explanation.


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

        Comment


        • #5
          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

          Comment

          Working...
          X