ping - Max Smirnov

 From:  Michael Gibson
6837.76 In reply to 6837.75 
Hi Max,

re:
> P.S. I don't know why but this script doesn't work without an alert dialog. I'll check it
> later (or maybe Michael will help us)

It's because setting img.src is asynchronous. When you set img.src it just initiates the image loading process - things are set up in HTML in this asynchronous way often times because it's designed for downloading stuff from remote servers which can take a while.

When you show the alert dialog, that runs a message loop and the timers for image loading are able to get triggered and finish the load.

You could remove the alert dialog though if you split the rest of your image processing functionality into a separate function and then get that set up on the image.onload event, img.onload should be called when the image is all ready.

- Michael