【发布时间】:2014-02-28 23:59:50
【问题描述】:
我已经使用了这里描述的方法:
http://ericbidelman.tumblr.com/post/14636214755/making-file-inputs-a-pleasure-to-look-at
以编程方式从按钮控件触发文件输入框。它在 Chrome 和 IE 中运行良好,但在 Firefox 中打开文件上传窗口两次。
以下帖子看起来很相似,我尝试将 stopPropagation 添加到点击事件,但没有任何区别。
jQuery - .on('click', ...) event fires two times in Firefox
jQuery click event fired twice in firefox but not in IE
谢谢。
编辑
相关的HTML是:
<button type="button" id="load_slow_button">Load Playlist</button>
<input id="load_slow_list" type="file" onchange="load_list(this.id)">
按钮的相关Javascript是:
document.getElementById("load_slow_button").addEventListener('click', function(event) {
document.getElementById("load_slow_list").click();
event.stopPropagation;
}, false);
文件输入的 Javascript 是一个标准文件处理程序,当手动单击文件输入时可以正常工作。
【问题讨论】:
-
请向我们展示您的代码
-
代码已添加...
标签: javascript html firefox click