How does js make it possible to pop up prompts when the user closes the browser (and tabs)?

    <script src="bootstrap-3.3.7/docs/assets/js/ie10-viewport-bug-workaround.js"></script>
<script data-main="js/main.js" src="js/lib/require.min.js"></script>
<script type="text/javascript">
    window.onbeforeunload = function (e) {
        var message = "";
        e = e || window.event;
    
        if (e) {
            e.returnValue = message;
        }
    
        return message;
    };
</script>


Apr.11,2021

you can use window.onbeforeunload .

example:

window.onbeforeunload = function (e) {
  e = e || window.event;

  // IE8Firefox 4
  if (e) {
    e.returnValue = '';
  }

  // Chrome, Safari, Firefox 4+, Opera 12+ , IE 9+
  return '';
};

Note: Chrome failure may be a version problem. Attach the change information starting from v51: Remove custom messages in onbeforeunload dialogs . It mentions "A window's onbeforeunload property no longer supports a custom string.." That is, custom strings are no longer supported.


is honored to be invited to answer.
I tried your own code and there are hints: chrome version 67.0.3396.87 (official version) will pop up, and this code already contains compatibility;
your own chrome is not good or other people's? Take a look at the version and whether the pop-up box is disabled: https://zhidao.baidu.com/ques.


chrome browser bug. It can be triggered as long as you open the console. Otherwise, it won't trigger.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e3c312-446ac.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e3c312-446ac.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?