You could mimic the Firefox behaviour with the following:
<input type="file" name="test" onkeypress="this.click();return false;">
When the user tries to type in the file input, it pops up the file chooser.
Obviously this won't work if the client has JavaScript disabled, but depending on your requirements, it might be "good enough".
Appears to work okay in IE 6, 7 and 8.
It works okay in Firefox 3 (since it doesn't allow typing in an <input type=file>
).
It works okay in Safari for Windows 3 & 4 (since it doesn't allow typing in an <input type=file>
).
In Opera 9 (which allows typing in an <input type=file>
) it doesn't do anything (doesn't pop up the chooser or swallow the keypresses). The onkeypress
event doesn't seem to fire at all actually, probably for security.
In Firefox 2 it does not work (which allows typing in an <input type=file>
) because this.click()
doesn't pop up the chooser and return false
swallows the keypresses.