diff --git a/assets/game1.js b/assets/game1.js index e657c69..c6d93f8 100644 --- a/assets/game1.js +++ b/assets/game1.js @@ -60,6 +60,15 @@ document.addEventListener('DOMContentLoaded', async () => { // Look for config injected by Twig in the page const cfgEl = document.getElementById('mercure-config'); + + // Prevent/warn on page reload + window.addEventListener('beforeunload', (event) => { + // Standard way to trigger the browser's confirmation dialog + event.preventDefault(); + // Included for compatibility with older browsers + event.returnValue = ''; + }); + if (!cfgEl) { console.warn('[Mercure][game1] #mercure-config element not found on page'); return;