diff --git a/public/js/lufi-down.js b/public/js/lufi-down.js index af98a41..142c9e1 100644 --- a/public/js/lufi-down.js +++ b/public/js/lufi-down.js @@ -71,7 +71,7 @@ function spawnWebsocket() { pbd.innerHTML = ''+i18n.download+''; ws.send('{"ended":true}'); - window.onbeforeunload = null; + window.removeEventListener('onbeforeunload', confirmExit); } else { if (ws.readyState === 3) { ws = spawnWebsocket(); @@ -93,5 +93,5 @@ document.addEventListener('DOMContentLoaded', function() { ws = spawnWebsocket(); // Prevent exiting page before full download - window.onbeforeunload = confirmExit; + window.addEventListener('onbeforeunload', confirmExit); }); diff --git a/public/js/lufi-up.js b/public/js/lufi-up.js index 9057099..9aaf6c6 100644 --- a/public/js/lufi-up.js +++ b/public/js/lufi-up.js @@ -96,7 +96,7 @@ function handleFiles(f) { // Create progress bar and call slicing and uploading function function uploadFile(i, delay, del_at_first_view) { // Prevent exiting page before full upload - window.onbeforeunload = confirmExit; + window.addEventListener('onbeforeunload', confirmExit); // Create a random key, different for all files var randomkey = sjcl.codec.base64.fromBits(sjcl.random.randomWords(8, 0), 0); @@ -233,7 +233,7 @@ function updateProgressBar(data) { uploadFile(i, delay, del_at_first_view); } else { // We have finished - document.onbeforeunload = null; + window.removeEventListener('onbeforeunload', confirmExit); document.getElementById('delete-day').removeAttribute('disabled'); document.getElementById('first-view').removeAttribute('disabled'); }