2

Is it possible to close the window that is opened by the click of an input file type using jquery/javascript ?

I have :

$("input[name=profileImage]").click(function(e){
    if(e.handled!=true){
       e.handled= true;
    }else{
       //Trigger close the pop-up or stop the file browse window from being shown
       e.preventDefault();// Does not work
       return false; //no change either 
    }
});

HTML Part :

<div class="control-group">
   <label class="control-label" for="form-field-1">Featured Image</label>
   <div class="controls span4">
      <input type="file" class="profileImage" name="profileImage" id="id-input-file-1" />
      <span class="help-button ace-popover" data-trigger="hover" data-placement="right" data-content="Image type should be jpg/png">?</span>
      <span>  Upload your photo here </span>
   </div>
</div>

I am using backbone framework and the templating is done using twitter bootstrap(The template is a paid one).

This is to prevent it from triggering a second time. I am facing this issue in firefox(windows) alone. Click of input type is triggering the browse window twice.

Roy M J
  • 6,926
  • 7
  • 51
  • 78
  • 1
    I'm pretty sure this is not possible and it would be better to solve the problem of double opening directly. Can you provide the code of your form? It sounds like there is an error. I hope you didn't do something like in this thread: http://stackoverflow.com/questions/16292487/why-file-open-dialog-opens-twice-on-clicking-the-button-in-firefox – tea2code Sep 12 '13 at 07:39
  • Okay ive added the html part. I have not done the html since, this is a template purchased by client and im simply using it..:(.. I do believe its some kind of event problem. – Roy M J Sep 12 '13 at 07:44
  • Does this problem persist if you remove class, name and id from the input? If not then there is somewhere javascript code which adds another event handler to it. – tea2code Sep 12 '13 at 08:00
  • hmm.. ill debug that way..ive got into the script part.. and its min file.. :( – Roy M J Sep 12 '13 at 09:19
  • ill also try extracting the file upload part only from the min file and create a fiddle also.. – Roy M J Sep 12 '13 at 09:20

0 Answers0