Sometimes, when you are doing some important works on your browser in one or multiple tabs, you accidentally close a tab or the whole browser window. This makes you fall in huge problem since you have to reload the page(s) and start the works (it can be writing a big Email, or a filling form) from beginning. This is potentially distracting. Though some browsers like Firefox and Internet Explorer tend to ask with a prompt dialog if we happen to close multiple tabs, Chrome lacks this feature. Maybe because Chrome focuses on simplicity. But sometimes, unintentionally closing an important tab throws us into nightmare.

Confirmation prompt when leaving page

Hopefully, a simple Chrome extension Lock Tab got us covered. With Lock Tab installed, you can just click on Lock Tab icon appearing on address bar, and that tab will be locked. Whenever you try to close the tab either by clicking on cross sign or Chrome close button, it will show you a prompted dialog asking you whether you want to leave the page or not. The dialog contains two buttons: Leave this Page, Stay on this Page.

Features of Lock Tab

  • Display a confirmation dialog.
  • Besides the address bar button, a keyboard shortcut can be set from settings page.
  • Option to freeze a page after locking.
  • Automatically lock all new pages on a locked tab.

How to Lock a Tab on Chrome using Lock Tab Extension

  1. Install Lock Tab from Chrome Web Store.
  2. Restart your Chrome to make the extension effective.
  3. Now open a page of which you want to lock the tab. Then click on the blue Lock Tab icon appearing at the end of address bar.
    Hit lock tab icon
  4. Instantly the tab will be locked with a change in the locker icon. A keyword “Locked” will also be added to the page title of the tab.
  5. Now whenever you click on close button, the following prompt will appear:
    Page leaving JavaScript prompt
  6. You can click “Stay on the Page” to not to leave the page.

You can access Lock Tab settings by right clicking on Lock Tab icon and choosing Options. Or head to Chrome Extensions page chrome://extensions.

Lock Tab Settings

How it Works

This technique works by simply injecting a JavaScript code in the page. You may have already stumbled this kind of “page leaving dialog” on some websites where it asks, “Are you sure you want to leave this page”? As the way it works, it’s unable to work on some Chrome special tabs including Gmail. Also, disabling JavaScript on Chrome will disable this extension’s functionality too.

Author: 

Jaber is a Programmer and Tech Enthusiast Geek from Dhaka, Bangladesh. He is the founder and Chief-Editor of TechGainer. While he is away from his keyboard, either he's fishing or messing with wildlife. In case, you can contact him at rijans[at]techgainer[dot]com.