[Javascript] Creating a DOM based Image Rotator

Triche Osborne wdlists at triche-osborne.com
Fri Aug 19 08:36:27 CDT 2005


Just an afterthought note on this:

> function rotate()
> {
>     if (curDocImg.complete)
>     {
. . .
>     }
> }
> 
If window.onload has not fired yet, curDocImg will have no properties. 
While this prevents the script from executing, it will throw a 
non-material error. A cleaner approach would be to change the if() test 
into something more suitable such as:

if(curDocImg)
or
if(curDocImg != null)

This has the same material effect has the original, but doesn't throw an 
error if window.onload hasn't fired.

Triche





More information about the Javascript mailing list