views:

728

answers:

1

When you render:

<input type="file" />

you get a box and a button, right? (At least in Firefox and IE.)

On the one hand, in Firefox you can only tab to (focus) the button, but in IE you can tab to (focus) both the box and the button.

On the other hand, I want to get IE to behave like Firefox, I mean, I need to get rid of the box focus. Think of the user navigating through the keyboard.

(The reason is because <input type="file" /> won't be visible. Instead, a <div> with a background-image will pretend to be the <input type="file" />.)

+1  A: 

If you're wanting to defer to the div, why not attach an OnFocus() event to the submit, and call the focus() event function on the div within the function:

$("#MySubmit").focus(function(){
  $("#MyDiv").focus();
});
James Wiseman
Can a div get focus? Anyways, if I press enter (navigating through the keyboard) when the div is on focus, I'll get no result. For security reasons, I can't open the browse dialog if I do anything other than click (or press enter) on the input-file button. So, things like this won't work:$("#MyDiv").click( function () { $("#MySubmit").click();}