Skip to content

Commit

Permalink
feat: test beforeunload compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Leoglme committed Feb 18, 2024
1 parent a09cfbb commit 701091f
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions public/mon-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});

0 comments on commit 701091f

Please sign in to comment.