We have an administrative portal that our teachers constantly forget to download their latest PDF instructions before logging out and/or closing the browser window. I have l
You cannot alert or things like that in onbeforeunload
, you cannot simply return false to make the user not leave the page, as with other events like onclick
. This would allow a site to make it impossible to leave it.
You can however just return a string, the browser then shows a confirm dialog including your string asking the user whether they really want to leave.