Skip to content

Instantly share code, notes, and snippets.

@apc518
Created December 27, 2021 13:18
Show Gist options
  • Save apc518/e3119089c041da9eb81536a9648390f4 to your computer and use it in GitHub Desktop.
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
<!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