Results 1 to 3 of 3

Thread: Time out for JavaScript

  1. #1

    Thread Starter
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    Post Time out for JavaScript

    >>> JS experts, anyone know how to set timeout in JavaScript?

    prog_tom
    JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
    http://physics.sviesoft.com/forum

  2. #2
    Hyperactive Member progressive's Avatar
    Join Date
    Sep 2001
    Location
    Manchester, UK
    Posts
    404
    simple really:

    setTimeout("myFunction()", 1000);

    1000 is equal to one second.

    example of how setTimeout should be used:

    Code:
    <html>
    <script language="javascript">
    
      var a = 0;
      // used as a reference to the timeout so that we
      //can stop the loop with clearTimeout
      var timeout_handle; 
      incrementCounter(a);
      
      function incrementCounter(x){
        
         current_loop = x + 1;
         alert("loop number" + current_loop);
         timeout_handle = setTimeout("incrementCounter(current_loop)", 3000);
      }
    </script>
    <body>
    <a href="#" onclick="clearTimeout(timeout_handle)">click here to stop the timeout</a>
    </body>
    </html>
    hope this helps you understand it more

  3. #3

    Thread Starter
    Fanatic Member prog_tom's Avatar
    Join Date
    May 2001
    Location
    Los Angeles and Little Rock
    Posts
    810

    Post Thanks Buddy

    Thanks.

    prog_tom
    JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
    http://physics.sviesoft.com/forum

Posting Permissions

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



Click Here to Expand Forum to Full Width