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.
source
share