View Full Version : An JavaScript question in firefox

09-26-2005, 04:24 PM
The following code runs very well in IE, but can't run properly in firefox.
The purpose is simple. I want to open the file select dialog after I click
the button labeled Open... instead of the input file object.

If anyone knows how to solve it, I will appreciate.

-------------------------- Code --------------------------

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<script language=javascript>
function OpenFile()
//document.getElementById("btnTest").click(); // This one has no question
document.getElementById("fileInput").click(); // This one can't work in firefox




<p><input type="file" id="fileInput" size="100"></p>
<p><button id="btnTest" onclick="alert('Test
<p><button onclick="OpenFile()">Open...</button></p>



09-26-2005, 06:48 PM
Hm. Its click() function does exist in Firefox, but nothing happens when it's called. Probably a security feature.