[thelist] Javascript - order of code execution

Edwin Martin edwin at bitstorm.org
Wed May 11 07:58:31 CDT 2005


Alex wrote:
> I am hoping there are some Javascript gurus out there that are able to 
> answer my seemingly simple, yet frustrating, problem.

This is normal behaviour. The user interface is updated 
*after* the JavaScript has finished.

The way to work around this is to split your code in two 
parts: the first part where you update the user interface 
and the second part, where you do the calculations.

The you call the second part with setTimeout().

Something like this:

function start() {
	// update interface here
	setTimeout( 'calculation()', 100 )
}

function calculation() {
	// Do your calculation here
}

Edwin Martin

-- 
http://www.bitstorm.org/edwin/en/



More information about the thelist mailing list