admin管理员组文章数量:1221306
This is a weird thing i noticed in chrome. if the user select a file and then select the same file again bu opening the file dialog again, chrome doesn't fire the onchange event while firefox does.
anybody noticed it as well?
This is a weird thing i noticed in chrome. if the user select a file and then select the same file again bu opening the file dialog again, chrome doesn't fire the onchange event while firefox does.
anybody noticed it as well?
Share Improve this question edited Oct 2, 2011 at 9:30 Bohemian♦ 425k100 gold badges599 silver badges745 bronze badges asked Jul 8, 2011 at 10:41 AmirAmir 1,2593 gold badges18 silver badges32 bronze badges 03 Answers
Reset to default 6This is a known feature of Chrome and a quick Google on the topic will bring up some interesting discussions.
It makes sense to me that the change
event wouldn't fire since nothing has changed (you're selecting the same file)
As for your question, what exactly are you asking? Are you looking for a way to change this behaviour or do you just want to know if we've noticed this as well?
If you want a way around this behaviour you can simply create a new file input in your Javascript and replace the previous one. This way your change
event is guarenteed to fire.
function resetFileInput($element) {
var clone = $element.clone();
$element.replaceWith(clone);
}
And then use:
$('#element_id').on('change', function(){
...
});
Worked well for me!
An easier solution to reset an input file that works well for me :
document.getElementById('idOfInput').value = '';
本文标签: javascriptinput file onchange event not being fired in chromeStack Overflow
版权声明:本文标题:javascript - input file onchange event not being fired in chrome - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739355835a2159596.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论