hook_onload() replacement
You don't use PHP hooks to execute Javascript. You would put the Javascript you want to execute into a .js file, and then use PHP to just attach that file to any page where it is needed, for example, using drupal_add_js().

For example if you wanted to attach it to every page with a certain type of form you would put drupal_add_js() inside of a hook_form_FORM_ID_alter). 

If you want it on every page all the time, you can add it to your module's .info file like so:

scripts[] 'path/to/js/foo.js