title: Execute JS on page load without using jQuery
body: <p>So I know that if you use jQuery you can use <code>$(document).load(function(){});</code> so that any code you write into the function gets executed after the whole page has loaded, but is there a way of doing something similar if you don't use jQuery and just use JS?</p>
  
  <p>For example...</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
          &lt;script type="text/javascript"&gt;
              var box = document.getElementById('box');
              alert(box);
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div id="box" style="width:200px; height:200px; background-color:#999; 
  margin:20px;"&gt;&lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;  
  </code></pre>
  
  <p>If I use this method the alert just says <code>null</code>. So is there a way of making the js code run once the page has loaded?</p>