JavaScript not working after Chrome update

Viewed 10447

I often accidentally close my Chrome browser and have to reopen and reload all the tabs that I'd been working on. Since Chrome does not a have built in confirm before closing mechanism, I wrote a simple page to ask for confirmation before closing. I leave that 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>

Recently I updated my Chrome browser from version 56 to 60. Now the code doesn't seem to work as it no longer asks for confirmation before closing. I tried many different variations from the internet but none seem to work.

Note: I am very new to web development.

1 Answers
Related