IE10 - Must click 2 times to submit form after cho

2019-04-27 18:07发布

问题:

In a form I have a file input skinned with jquery and css and a submit button.

<form action="#" method="POST">
  <input style="width:150px" type="hidden" name="MAX_FILE_SIZE" value="40000"/>
  <div class="l-input-file">
    <input style="margin-bottom: 0px" type="file" id="myInput" name="myInput" size="16" />
  </div>
  <div><button type="submit" class="btn-black">Continuer</button></div>
</form>

http://jsfiddle.net/CsL9t/

The matter here appear only on IE10: After a file has been selected the submit button must be clicked 2 times to be able to submit the form.

I tried forcing the focus on the button when the file input change but it doesn't help.

I tried triggering the click using jQuery,

jQuery('#myInput').parents('form').find("button[type='submit']").click();

but I received 2 times the message 'access denied' before submitting the third time.

Any input or advice will be strongly appreciated. Thanks

回答1:

$input.trigger('click'); is what causes the access denied error.
Triggering a click event on a file input taints a file input in IE preventing(to some extent) you from submitting the form or using it with a FormData object.

See also getting access is denied error on IE8