No window.onload = rotate(); is not correct way to attached a function to onload event. As I told you before window.onload = rotate(); will first call it (before the page is rendered as you have put this code before <img src='image.jpg' name='banner'> is rendered on document ) and then it will be assigned to onload event.
I used if-condition to bypass the first call to rotate as at that time <img> tag was not rendered in the document and hence document.banner was undefined leading to crash when try to apply property to undefined object (document.banner.src).
So few points you should note about above code:
1) function name followed by () will call it.
2) always check if the object is defined before applying any properties.
Thankyou
When you think you have done a lot, then be ready for YOUR downfall.