views:

384

answers:

1

I am trying to focus on the browse button of the file input control.

so I have something like

 <input type="file" name="upload" id="upload" >

and in javascript I have

document.getElementById("upload").focus();

but the focus remain on the text field and comes to browse button only after i hit tab. Is there a way that I could write a script to set the focus on the browse button?

Thanks for your help!

+1  A: 

Can't be done. You have almost zero control over the constituent parts of a file upload field, partly for security reasons and partly because the standards do not define what constituent parts a file upload field might have. It is entirely possible the browser might render a file upload interface without any ‘Browse’ button.

bobince