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 = '';