I am using infile to ask the users to browse for a file on their machine. Is there way to catch if the window is closed without file being selected?
For example if x i
With the solution from HTML input file selection event not firing upon selecting the same file, I think you can use this:
var fileElem = document.getElementById("inFile");
var fileSelected = null;
fileElem.onclick = function(e) {
fileSelected = this.value;
this.value = null;
});
/* or use this in your browse() function:
fileElem.value = null;
*/
fileElem.onchange = function(e) { // will trigger each time
handleFileDialog(this.value === fileSelected);
};
function handleFileDialog(changed) {
// boolean parameter if the value has changed (new select) or not (canceled)
}