mirror of
https://github.com/kiwix/kiwix-js-pwa.git
synced 2025-09-09 12:19:46 -04:00
parent
05b1ee6305
commit
3154de3e3c
@ -32,6 +32,18 @@ window.onerror = function (msg, url, line, col, error) {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Set a beforeUnload handler to prevent app reloads without confirmation if a ZIM file is loaded
|
||||||
|
window.addEventListener('beforeunload', function (event) {
|
||||||
|
if (appstate && appstate.selectedArchive && params.appCache) {
|
||||||
|
var confirmationMessage = 'Warning: you may have to reload the ZIM archive if you leave this page!';
|
||||||
|
event.preventDefault();
|
||||||
|
// Included for legacy support, e.g. Chrome/Edge < 119
|
||||||
|
event.returnValue = confirmationMessage;
|
||||||
|
// For modern browsers
|
||||||
|
return confirmationMessage;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides caching for assets contained in ZIM (variable needs to be available app-wide)
|
* Provides caching for assets contained in ZIM (variable needs to be available app-wide)
|
||||||
* It significantly speeds up subsequent page display. See kiwix-js issue #335
|
* It significantly speeds up subsequent page display. See kiwix-js issue #335
|
||||||
|
Loading…
x
Reference in New Issue
Block a user