title: Javascript focus on input box on load
body: <p>No matter what I do, this page doesn't work at all. I want it to focus on the input box on load.</p>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Home Screen&lt;/title&gt;
  &lt;style type="text/css"&gt;
  input {border:0px;}
  input:focus {outline:none;}
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body onload="document.getElementById("search").focus()"&gt;
  &lt;input id="search" /&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I know I'm breaking a bunch of rules with this code, so you don't need to say anything about that.</p>
  
  <p>EDIT:</p>
  
  <pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Home Screen&lt;/title&gt;
  &lt;style type="text/css"&gt;
  input {border:0px;}
  input:focus {outline:none;}
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body onload="document.getElementById('search').focus()"&gt;
  &lt;input id="search" onblur="setTimeout(document.getElementById('search').focus(),10)" /&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>EDIT 2:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function refocus()
  {
  setTimeout(document.getElementById("search").focus(),10);
  }
  &lt;/script&gt;
  
  &lt;input id="search" onblur="refocus()" /&gt;
  </code></pre>