JavaScript and the DOM share the same thread, so the display cannot refresh whilst script is currently executing. It has to wait until the thread becomes idle. You can only achieve what you're trying to do with a setTimeout or setInterval call, increasing each step with a timer instead of a loop.
Andy E
2010-02-23 15:02:32