title: How do I call a JavaScript function on page load?
body: <p>Traditionally, to call a JavaScript function once the page has loaded, you'd add an <code>onload</code> attribute to the body containing a bit of JavaScript (usually only calling a function)</p>
  
  <pre><code>&lt;body onload="foo()"&gt;
  </code></pre>
  
  <p>When the page has loaded, I want to run some JavaScript code to dynamically populate portions of the page with data from the server. I can't use the <code>onload</code> attribute since I'm using JSP fragments, which have no <code>body</code> element I can add an attribute to.</p>
  
  <p>Is there any other way to call a JavaScript function on load? I'd rather not use jQuery as I'm not very familiar with it.</p>