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