diff --git a/modules/pi_control/assets/console.js b/modules/pi_control/assets/console.js index fbd5953..0a13946 100644 --- a/modules/pi_control/assets/console.js +++ b/modules/pi_control/assets/console.js @@ -1,13 +1,4 @@ (() => { - 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; @@ -107,9 +98,15 @@ iframe.addEventListener('load', () => { try { - if (iframe.contentWindow) { + const clearUnload = () => { + if (!iframe.contentWindow) return; iframe.contentWindow.onbeforeunload = null; - } + if (iframe.contentWindow.document) { + iframe.contentWindow.document.onbeforeunload = null; + } + }; + clearUnload(); + setInterval(clearUnload, 2000); const doc = iframe.contentWindow.document; ['keydown', 'mousedown', 'wheel', 'touchstart'].forEach((evt) => { doc.addEventListener(evt, markActive, { passive: true });