chrome中没有触发输入文件onchange事件 [英] input file onchange event not being fired in chrome

查看:158
本文介绍了chrome中没有触发输入文件onchange事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个奇怪的事情,我注意到在铬。如果用户选择一个文件,然后再次选择相同的文件,再次打开文件对话框,chrome将不会在firefox发生onchange事件。



任何人注意到

解决方案

这是Chrome的一个已知功能,并且快速 Google的话题将带来一些有趣的讨论。



对我来说,更改事件不会触发,因为没有任何变化(您选择相同的文件)



至于你的问题,你到底是什么问?您是否正在寻找一种改变这种行为的方法,或者您只想知道我们是否也注意到了这一点?



如果您想要绕过此行为,可以简单地在您的Javascript中创建一个新的文件输入并替换前一个。这样您的更改事件是必须触发的。


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 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.

这篇关于chrome中没有触发输入文件onchange事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆