Add beforeunload

This commit is contained in:
kwaroran
2024-09-06 00:16:52 +09:00
parent a16a9c7e8b
commit cd83867d21

View File

@@ -20,6 +20,15 @@ export function preLoadCheck(){
localStorage.setItem('mainpage', searchParams.get('mainpage'));
}
if(isWeb) {
//Add beforeunload event listener to prevent the user from leaving the page
window.addEventListener('beforeunload', (e) => {
e.preventDefault()
//legacy browser
e.returnValue = true
})
}
// Redirect to the main page if the user has not visited the main page
if(localStorage.getItem('mainpage') !== 'visited') {