From 701091f59885f9d833e60a4e1f4aa6d17ef90fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Guillaume?= Date: Sun, 18 Feb 2024 04:49:56 +0100 Subject: [PATCH] feat: test beforeunload compatibility --- public/mon-script.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/public/mon-script.js b/public/mon-script.js index eedc176..c4760a9 100644 --- a/public/mon-script.js +++ b/public/mon-script.js @@ -5,17 +5,22 @@ // confirmFirst('beforeunload') // }) -window.addEventListener('pagehide', () => { - confirmFirst('pagehide') - -}) +// window.addEventListener('pagehide', () => { +// confirmFirst('pagehide') +// +// }) +// +// confirm('v4') +// +// function confirmFirst(eventName) { +// if(confirm("Leave the page?" + eventName)){ +// console.log("You are leaving the page") +// }else{ +// return false; +// } +// } -confirm('v4') -function confirmFirst(eventName) { - if(confirm("Leave the page?" + eventName)){ - console.log("You are leaving the page") - }else{ - return false; - } -} +document.addEventListener("visibilitychange", () => { + alert(document.hidden) +});