In Drupal 4.7 and 5.x correct way to add your custom Javascript onload events is to
a) Make sure there is no onload attribute on HTML body tag.
b) Make sure you are not calling window.onload= directly
c) Insert the following snippet, in the generic section (outside any methods!) of your module’s javascript file:

if (isJsEnabled()) {

You can call addLoadEvent method as many times as you wish. It will stack-up multiple functions and call them in queue.