Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

JavaScript innerHTML Won't Update While Script is Running?

I am appending text to document.body.innerHTML, but it doesn't appear in the document until after my script terminates. The code works fine; the output is just not visible. [When I use Firebug, I can see the correct output every time it stops at a breakpoint.]

I am trying to simulate an old-style CGA environment: upper-case white text on a black background with 80 characters per line and 16 lines on the screen (you probably won't remember the TRS-80 unless you're over 30). This means I have to write four functions: inputChar, outputChar, inputLine, and outputLine. Not a big deal, but the user can't view the output until the script terminates. The trouble is that the script can't terminate until we go through the input, output, input, output many times - the ultimate catch-22.

While typing, I figured out that I can redesign the code to make everything trigger on the user's keypress, but that's a major logic rewrite. Can you think of any other way I can show the output immediately rather than after the script terminates?

2 Answers

Relevance
  • 9 years ago
    Favorite Answer

    what is triggering your script now? Just running at loading? Whatever scripts need to run at loading have to finish first.

    You could try starting your script with a timer, leave it as is but not be triggered at loading, but I have a feeling the keyboard trigger will be much better.

  • ?
    Lv 4
    4 years ago

    OMG you're literally the coolest person I definitely have ever met (or examine from). All of those books are stunning and that i only can not see The Witches and Animal Farm are banned. they might as properly inform you the only ingredient you could watch is the information on television and nonetheless block the comments concerning to the middle East. you have graduated by now i assume so did you smash out with it for something of your intense college occupation? you're are only freaking remarkable, I desire you have been here proper now so i might desire to purchase you a machiatto or some thing from Starbucks. You circulate female, like that's remarkable. that's unquestionably you could tell human beings as a tale or some thing. you're freaking awesome. I salute you and wager you're off now doing some thing awesome along with your life. Congratulations! you're an thought to this variety of great form of infants. Like besides the fact that in case you got like suspended or some thing (even however that's not sturdy in any respect) a minimum of it could have been some thing cool and remarkable. only... you circulate female,:)

Still have questions? Get your answers by asking now.