I have an aspx that has the following javascript function being ran during the onload event of the body.
The cleanest way is using a javascript framework like jQuery. In jQuery you could define the on-load function in the following way:
$(function() { // ... });
Or, if you don't like the short $(); style:
$();
$(document).ready(function() { // ... });