title: How can you set focus to an HTML input element without having all of the HTML?
body: <p>First, the background:
  I'm working in Tapestry 4, so the HTML for any given page is stitched together from various bits and pieces of HTML scattered throughout the application. For the component I'm working on I don't have the <code>&lt;body&gt;</code> tag so I can't give it an <code>onload</code> attribute.</p>
  
  <p>The component has an input element that needs focus when the page loads. Does anyone know a way to set the focus to a file input (or any other text-type input) on page load without access to the body tag?</p>
  
  <p>I've tried inserting script into the body like
  <br /><code>document.body.setAttribute('onload', 'setFocus()')</code>
  <br />(where setFocus is a function setting the focus to the file input element), but that didn't work. I can't say I was surprised by that though.</p>
  
  <p><b>EDIT:</b><br />
  As has been stated, I do indeed need to do this with a page component. I ended up adding file-type inputs to the script we use for giving focus to the first editable and visible input on a page. In researching this problem I haven't found any security issues with doing this.</p>