Created
December 27, 2021 13:18
-
-
Save apc518/e3119089c041da9eb81536a9648390f4 to your computer and use it in GitHub Desktop.
This html/javascript produces a strange behavior on Chromium, but not on Firefox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<style> | |
#droparea { | |
min-height: 200px; | |
background-color: rgb(25, 180, 89); | |
} | |
</style> | |
</head> | |
<body> | |
<div id='droparea'>File drop</div> | |
<script> | |
const fileDropArea = document.getElementById('droparea'); | |
fileDropArea.addEventListener('dragover', e => { | |
e.preventDefault(); | |
e.stopPropagation(); | |
e.dataTransfer.dropEffect = 'copy'; | |
}); | |
fileDropArea.addEventListener('drop', e => { | |
e.preventDefault(); | |
e.stopPropagation(); | |
console.log("before loop:", e.dataTransfer.files); | |
for(let f of e.dataTransfer.files){ | |
f.arrayBuffer().then(res => { | |
console.log("no more files??", e.dataTransfer.files); | |
}); | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment