...

View Full Version : An JavaScript question in firefox



ShongTu
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 --------------------------
<html>

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

<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
}

//-->
</script>

</head>

<body>

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

</body>

</html>

nikkiH
09-26-2005, 07:25 PM
This event is not defined in the specs for file input elements.
IE only.

http://www.w3.org/TR/2000/WD-DOM-Level-2-HTML-20001113/html.html#ID-2651361
click
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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum