IE10 - 选择文件上传后必须点击2次提交表格 [英] IE10 - Must click 2 times to submit form after choosing a file to upload

查看:201
本文介绍了IE10 - 选择文件上传后必须点击2次提交表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < form action =在一个表单中我有一个用jQuery和css以及一个提交按钮进行皮肤输入的文件。 #method =POST> 
< input style =width:150pxtype =hiddenname =MAX_FILE_SIZEvalue =40000/>
< div class =l-input-file>
< input style =margin-bottom:0pxtype =fileid =myInputname =myInputsize =16/>
< / div>
< div>< button type =submitclass =btn-black> Continuer< / button>< / div>
< / form>

http://jsfiddle.net/CsL9t/



这个问题只出现在IE10上:选择一个文件后,必须点击提交按钮2次才能提交表格。





当文件输入发生变化时,我尝试使用jQuery触发点击,

$ p $ j $ jQuery('#myInput')。parents('form')。find(按钮[类型= '提交'])点击();

但在第三次提交之前,我收到了2次拒绝访问的消息。



任何意见或建议将不胜感激。
谢谢

解决方案

$ input.trigger('click');
在文件输入上触发一个点击事件会阻止IE中的文件输入,从而防止(在某种程度上)提交表单或将其与 FormData 对象。



另请参阅在IE8上访问被拒绝错误


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

解决方案

$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

这篇关于IE10 - 选择文件上传后必须点击2次提交表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆