Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question An JavaScript question in firefox

    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>

  • #2
    Senior Coder nikkiH's Avatar
    Join Date
    Jun 2005
    Location
    Near Chicago, IL, USA
    Posts
    1,973
    Thanks
    1
    Thanked 32 Times in 31 Posts
    This event is not defined in the specs for file input elements.
    IE only.

    http://www.w3.org/TR/2000/WD-DOM-Lev...tml#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

    If this post contains any code, I may or may not have tested it. It's probably just example code, so no getting knickers in a bunch over a typo, OK? If it doesn't have basic error checking in it, such as object detection or checking if objects are null before using them, put that in there. I'm giving examples, not typing up your whole app for you. You run code at your own risk.
    Bored? Visit
    http://www.kaelisspace.com/

  • #3
    New to the CF scene
    Join Date
    Sep 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Oh. I see. Thank you very much.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •