Place the call to the external .js file in the <head> section,
but of course any HTML elements referenced must exist at the moment the script is called. Probably that is why the script is called onload.
If the script refers to HTML elements, try placing the call right after the location where they are defined.
All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Last edited by Philip M; 02-05-2013 at 05:14 PM..