JavaScript does not work after updating Chrome

I often accidentally close the Chrome browser and have to re-open and reload all the tabs that I worked on. Since Chrome does not have built-in confirmation before the close mechanism, I wrote a simple page to request confirmation before closing. I leave this page open among my other tabs.

<!DOCTYPE html>
<html>
    <body>
    <p>This page is to prevent accidental closing of Chrome.</p>
        <script language="JavaScript">

            window.onbeforeunload = function () {
                return "Are you sure?";
            };
        </script>
    </body>
</html>

I recently updated the Chrome browser from version 56 to 60. Now the code does not work, because it no longer asks for confirmation before closing. I have tried many different options from the internet, but no one works.

Note. I am very new to website development.

+4
source share
1 answer

MDN docs:

, , beforeunload, ; .

, , , ,  Chrome 60 . :

Chrome 60, beforeunload , , , ( - ).

, , - .

, , Chrome, Ctrl-Shift-T.

+3

Source: https://habr.com/ru/post/1683664/


All Articles