javascript - input type = file cancellation case
習慣沉默
習慣沉默 2017-06-13 09:24:15
0
2
2226
<input type="file">, 点击出现对话框,有无办法监听到用户点击对话框中取消按钮的事件?望大神赐教。
習慣沉默
習慣沉默

reply all(2)
大家讲道理

If I remember correctly, there will also be onChange when clicking cancel, and the value should be undefined.

为情所困

onchange can be detected by clicking Cancel on Chrome, but not on Firefox. If your project is only on mobile devices, you can try onchange like this. If you want to consider PC, you can bind an additional click event specifically for detection. When onchange is triggered, you can ignore click. When click is triggered, but onchange is not triggered or the same file is selected, it means that the user has not Change the file selection or click Cancel. . .

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template