Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 121517
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:59:00+00:00 2026-05-11T03:59:00+00:00

I know at first glance (due to the title) this looks like one of

  • 0

I know at first glance (due to the title) this looks like one of the ‘Did you try searching Google before posting?’ questions, but I can’t seem to find an answer for the specific issue I’m experiencing. Sorry if I’m a noob…. still learning 🙂

I need to simulate a pause in javascript, but the setTimeout(function_call, timeout) function is not working for me. Reason being… when that setTimeout function is called, it then makes the function call asynchronously.

A little background:
I’m trying to simulate text being typed into a div at randomly timed intervals. I want it to appear as if a person is actually typing a message while the user is viewing the page. Since the timeout is a random interval and the function call is made asynchronously, the text ends up being printed in a random order.

Here is a snippet of what I have thus far:

typeString: function(s) {     for(var i=0;i<s.length;i++)     {                               var c = s.charAt(i);         var temp = setTimeout('MessageType.typeChar('' + c + '')', this.genRandomTime());     } } 

Thanks in advance for your help.

CJAM

UPDATE: By adding the timer delay to a varialbe, it enabled me to offset timeOut for the asynchronous calls. Thank you all for your quick responses. Here is the updated code:

typeString: function(s) {     var delay = 0;      for(var i=0;i<s.length;i++)     {                              var c = s.charAt(i);         setTimeout('GoogleTyper.typeChar(''+c+'')', delay += this.genRandomTime());     } } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:59:01+00:00Added an answer on May 11, 2026 at 3:59 am

    Have you tried cumulatively setting the timeout? Stick a variable outside of your loop and initialize it to 0. Let’s call it timeout for now. Add a random amount of time to this variable at the beginning of each iteration of your loop, and make the timeout work off of that. This way, you are ensured that functions are being called in order.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's get this out of the way first: I know that SessionFactory is immutable
First of all i don't know whether the title is relevant or not (please
First of all I don't know if this is the right approach. I want
First let me say i dont know if this is possible the way im
first of all i would like to say i know its probably an easy
Does any body know first-child and last-child support old IE like IE6 and IE7.
I know that many people, at a first glance of the question, may immediately
This might at first glance seem rather similar to this question , but in
To begin with, I don't know the first thing about Python ... so I
First you should know I have looked into many questions and none of them

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.