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?
Definition and UsageThe onchange attribute fires the moment when the value of the element is changed. Tip: This event is similar to the oninput event. The difference is that the oninput event occurs immediately after the value of an element has changed, while onchange occurs when the element loses focus.
The onchange event occurs when the value of an element has been changed. For radiobuttons and checkboxes, the onchange event occurs when the checked state has been changed.
The Onchange Event Handler in Javascript is an event handler that is triggered when a user changes something within a form element. An example of this is a drop-down selection menu, where a user selects a new option from a list of choices.
This 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With