Connecting Tech Pros Worldwide Help | Site Map

How to trigger file input .click() event in Firefox

Newbie
 
Join Date: Sep 2007
Posts: 2
#1: Sep 20 '07
Hi i got a file input object, but i want it to be hidden, and then i user a picture as button to trigget that hidden file input object, the thing is it works fine on IE, but on Firefox wont do anything, not even errors, anyone knows how to trigger the click() event on Firefox?

Here is my code:

[HTML]function open_filebrowser(){
document.getElementById("fileBrowse").click();
}

<input type=file id='fileBrowse' style='display:none;'>
<img id="bf" src="graphics/open.gif" style='cursor:pointer;' onclick='open_filebrowser();'>[/HTML]
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#2: Sep 20 '07

re: How to trigger file input .click() event in Firefox


Opera and Firefox don't support the click() method for input file elements.

However, see Styling an input type="file"
acoder's Avatar
Site Moderator
 
Join Date: Nov 2006
Location: UK
Posts: 14,581
#3: Sep 20 '07

re: How to trigger file input .click() event in Firefox


Changed the thread title to better describe the problem.
Reply


Similar JavaScript / Ajax / DHTML bytes