View Full Version : An JavaScript question in firefox

09-26-2005, 06:39 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, 07:25 PM
This event is not defined in the specs for file input elements.
IE only.

Simulate a mouse-click. For INPUT elements whose type attribute has one of the following values: "Button", "Checkbox", "Radio", "Reset", or "Submit".
No Parameters
No Return Value
No Exceptions

09-27-2005, 07:52 AM
Oh. I see. Thank you very much.