title: Body onload function in JavaScript
body: <p>I have the code that I have posted below in my webpage. As you can see it uses the <strong>body onload</strong> function to launch the script. Is there any way of making this script work without this and in JavaScript instead?</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
  
  &lt;script type="text/javascript"&gt;
  function box(query){
  return document.getElementById(query)
  }
  &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body onload="box('query').focus();"&gt;
  
  &lt;input id="query" type="text"&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thanks in advance,
  Callum</p>