Potresti postare un mini-esempio? Un codice del genere

codice:
<html>
  <script>
    function g() {
      alert("g()");
    }
	
    window.onload = function() {
      g();
    } 
  </script>
  <body>
	
  </body>
</html>
produce il risultato atteso.