Make Chrome Warn You When Closing Multiple Tabs

This guide will show you how to configure Chrome so that it gives you a warning before you exit the browser, saving you from accidentally closing all of your open tabs etc.

Unlike other modern browsers like Firefox and Safari, Chrome does not ‘warn’ you when closing your browser if multiple-tabs are open. Once upon a time there was an extension that provided this functionality (it was made by Google in fact) but it has since been retired. Also, it only worked for Windows users.

Fast forward to 2021 and although the functionality still hasn’t been added to Chrome, there’s an easy enough workaround. If you load some simple javascript into a tab in Chrome, it will force a window to pop up when you try to close that tab. Just copy and paste this code into a file and name it something like warn.html

var unloadEvent = function (e) {
var confirmationMessage = "Do you want to close this?";
(e || window.event).returnValue = confirmationMessage; //Gecko + IE
return confirmationMessage; //Webkit, Safari, Chrome etc.
window.addEventListener("beforeunload", unloadEvent);
<title>Warn Before Close</title>
<h3>Click somewhere on this page to activate</h3>
Make sure to click somewhere on this page. Once you do, you won't be able to close this tab without clicking a <strong>Leave</strong> button first.

Open that file in Chrome (and then click somewhere inside the window) and then try to close Chrome. You’ll see a pop-up message that forces you to click a Leave button before it actually closes that tab.

a warning message in Chrome that appears when you close the tab

I’ve also put a page up at:

that you can use if you wish.

If this article helped you, I'd be grateful if you could share it on your preferred social network - it helps me a lot. If you're feeling particularly generous, you could buy me a coffee and I'd be super grateful :)

buy a coffee for

Home » Chrome » Make Chrome Warn You When Closing Multiple Tabs

1 thought on “Make Chrome Warn You When Closing Multiple Tabs”

  1. This works like a charm! Thank you so much for your help with this long-standing problem I have had. Wish I had found this helpful information earlier

Leave a Comment

Your email address will not be published.