diff --git a/modules/pi_control/assets/console.js b/modules/pi_control/assets/console.js index ca84887..fbd5953 100644 --- a/modules/pi_control/assets/console.js +++ b/modules/pi_control/assets/console.js @@ -1,4 +1,13 @@ (() => { + window.addEventListener( + 'beforeunload', + (e) => { + e.stopImmediatePropagation(); + e.preventDefault(); + e.returnValue = undefined; + }, + { capture: true } + ); const tabBar = document.querySelector('[data-console-tab-bar]'); const tabPanels = document.querySelector('[data-console-tab-panels]'); if (!tabBar || !tabPanels) return; @@ -98,6 +107,9 @@ iframe.addEventListener('load', () => { try { + if (iframe.contentWindow) { + iframe.contentWindow.onbeforeunload = null; + } const doc = iframe.contentWindow.document; ['keydown', 'mousedown', 'wheel', 'touchstart'].forEach((evt) => { doc.addEventListener(evt, markActive, { passive: true });