Often, I find myself accidentally closing my Chrome browser and having to go through the tedious process of reopening and reloading all the tabs I had been working on. Frustrated with Chrome's lack of a built-in confirmation mechanism before closing, I took matters into my own hands by creating a simple page that prompts for confirmation before the browser is closed. I keep this page open alongside my other tabs.
<!DOCTYPE html>
<html>
<body>
<p>This page serves to prevent accidental closure of Chrome.</p>
<script language="JavaScript">
window.onbeforeunload = function () {
return "Are you sure?";
};
</script>
</body>
</html>
However, after updating my Chrome browser from version 56 to 60, the code no longer functions as intended. It no longer asks for confirmation before closing, despite trying various solutions found online without success.
Disclaimer: I am relatively new to web development.