> What I don't understand is why even use the Date object?

Browsers can be slow. If you asked for a timeout in 20 milliseconds doesn't
mean you're going to get one. If it takes 40 milliseconds for the browser to
render the change you make in your animation (or the CPU is busy doing
something else), by the time you get called back the clock will be much
further on than you think. The animation would go on twice as long as it
should and eat the CPU whilst it's at it.

It's often better to have a fixed amount of time for an animation to execute,
and if the browser is slow just show fewer frames in the same time, a jerkier
version of the animation.

> setInterval since 1.2. Version 4 of both Netscape and IE support 1.2.

I personally don't find intervals ideal either. Again, if the animation takes
longer than the interval, intervals will hog the CPU, and return to you an
unnecessary number of times, piling up in a queue as you fail to handle them
in time. I have always used timeouts for animation.

Here is a version of Eric's page with animation provided by timeouts:


(warning: uses JavaScript's prototype-based object system to factor out the
animation code into Effect classes. This may be a bit weird if you're not used
to it. Also, retains the IE-incompatibility of the original - easy to fix but
not an issue related to this one.)