What options do I have to prevent the user from just closing the browser or switching to another site? (of course, I can’t stop him from pulling the plug onto the computer, etc .: I just want to show him a warning)
To achieve this, you can use the JS event beforeunload.
beforeunload
You must use the onunload event.
<script> function onExitHandler() { // called when user about to leave the page } </script> <body onunload="onExitHandler()"> ... </body>
Here you can see an example: http://www.w3schools.com/jsref/jsref_onunload.asp
Source: https://habr.com/ru/post/1615229/More articles:Apache Commons Imaging Maven Dependency - javaКак очистить данные из Википедии по категориям? - pythonHow to create a NullObject template using RxJava - androidChecking unsaved changes when switching views in backbone.js - javascriptGIT: error: pathspec 'xxx does not match any file known as git - gitObject oriented design - when to use getClass and instanceof - javaWhat is EXECUTE IMMEDIATE for? - oracleEXECUTE IMMEDIATE temp table in oracle not created ORA-00942 - sqlGlobal temporary table - multithreadingHow do I enable non-interactive authentication when deploying a web project using Azure Webjobs and schedules? - certificateAll Articles