Add beforeunload

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

View File

@@ -19,6 +19,15 @@ export function preLoadCheck(){
else if(searchParams.has('mainpage')) { else if(searchParams.has('mainpage')) {
localStorage.setItem('mainpage', searchParams.get('mainpage')); 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 // Redirect to the main page if the user has not visited the main page