Maybe in case he's got a page structure like
include ('header-inc.php'); // all the stuff from <html> until <body> here
do your stuff for the main
include('footer-inc.php');
There you'd have to include it outside the header. I also noticed that loads of webfiliters like Webwasher could be oblivious to things declared later in the program. You can even just call a function later in the script and circumvent onload altogether - just make sure all the elements the script might reference are present before it's called.