You don’t need to use onload when you put the JavaScript where it belongs - just before the </body> tag.
</body>