[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [CF-Scripting] Simulate click() in <input type="file">



Tim Blair wrote:

- see footer for list info


Hello,

Does anyone know how to use JavaScript to simulate a click on the
"Browse..." button of a file upload form field?

In IE I can use something like document.myForm.myFile.click() which will
do the job and pop open the file browse window, but this doesn't work in
Firefox (no error, just doesn't do anything).

Any ideas?


Its a bit long winded, but take a look at this article on styling a file input.

http://www.quirksmode.org/dom/inputfile.html

I haven't digested it all, but right at the bottom the guy makes mention of not being able to use the click() method with Mozilla and Opera. This seems to suggest that perhaps his styling solution may help you with your click() problem.

Hope it helps

Stephen