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

  • SEARCH
  • Home
  • 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 9041327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T10:12:53+00:00 2026-06-16T10:12:53+00:00

I want to pause execution in javascript so that I can animate the appearance

  • 0

I want to pause execution in javascript so that I can animate the appearance of text on the screen. My code is currently this:

function AnimateWord(word) {
    for (var i = 0; i <= word.length; i++) {
        myTest.textContent += word.charAt(i);
        // need to pause here and then continue
    }
}

I’ve done some research and the preferred method to do this in javascript seems to be setTimeout, although I can’t really see how that would work in this case without creating a recursive loop (which just doesn’t seem like the right solution to me).

Is there a way around this, or am I stuck with setTimeout and a recursive loop?

EDIT:

Based on some additional tests, I’ve tried using the Promise.timeout:

for (var i = 0; i <= word.length; i++) {
    WinJS.Promise.timeout(1000).then(TypeLetter(word.charAt(i)));
}

function TypeLetter(letter) {
    myTest.textContent += letter;
}

But this doesn’t seem to actually pause. In fact, it seems to completely ignore the timeout. I’ve also tried:

setTimeout(TypeLetter(word.charAt(i)), 1000);

With basically the same results. this page seems to imply that it should wait and then execute the task. I’m quite new to WinJS, but am equating a promise to an await keyword in C#.

  • 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. Editorial Team
    Editorial Team
    2026-06-16T10:12:54+00:00Added an answer on June 16, 2026 at 10:12 am
    var i = 0;
    var str = "plz send teh codez";
    var intervalId = setInterval(function(){
        myTest.textContent += str.charAt(i);
        if (++i >= str.length)
            clearInterval(intervalId);
    }, 1000);
    

    demo http://jsfiddle.net/qxfVu/1/

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

Sidebar

Related Questions

I am executing a function and i want to pause execution for some time.
Let's say I want to pause a thread so that other threads can run
Can I pause execution from within JS code? I am working on a simple
I want to pause UIImageView animation and based on my research found that you
I want to pause the timer thread....or i can say want to put it
i want to play the video of this URL http://www.youtube.com/watch?v=JPUWNcGDyvM&feature=player_embedded where i PAUSE last
I'm currently working on some concurrent code that would appear to have a few
I want my script's execution to pause for about a half of a second.
I use a MacBook Pro. Sometimes I want to pause the execution of a
How we can execute a javascript function and get a return value in our

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.