利用其它控件触发file的click事件来选择文件后,使用jquery.form.js中的submit方法提交时IE报错:form.submit SCRIPT5: 拒绝访问,其它浏览器正常,

<script>
function fileclick(){
    $("#file1").click();
}
$(function(){
    $("#btnSumbit").click(function(){
        $("#form1").ajaxSubmit();
    });
})
</script>

出问题的代码如下:

<form >
  <input type="file" />
  <a herf="javascript:void(0)" onclick="fileclick()">上传附件</a>
<input type="button" /> </form>

解决办法:label的for属性指向file

<form >
  <input type="file" />
  <label for="file1" style="cursor:pointer;">上传附件</label>
<input type="button" /> </form>

 

相关文章:

  • 2021-04-09
  • 2022-02-05
  • 2022-12-23
  • 2021-11-20
  • 2022-02-08
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
  • 2021-11-02
  • 2021-11-28
  • 2021-04-12
相关资源
相似解决方案