The "real" way is via the DOM.
var s = document.createElement("script");
var nodes = document.getElementsByTagName("*");
var node = nodes[nodes.length -1].parentNode;
A well defined way to say "The page is loaded, all your variables and objects are loaded, Time to execute!" rather then "You can only see the variables and objects that are defined 'above' you and not 'below' you in unloaded portions of the page".
window.onload is the DOM event you're looking for.