IE10 - Must click 2 times to submit form after choosing a file to upload

风流意气都作罢 提交于 2019-12-07 03:27:38

问题


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



来源:https://stackoverflow.com/questions/18624863/ie10-must-click-2-times-to-submit-form-after-choosing-a-file-to-upload

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!