Are you sure you want to leave this page? How to escape websites that don't want you to leave

'Are you sure you want to leave this page?' It's a question most of us will have been asked by our browser. Yes, we do. Don't we? Maybe we should leave it open just in case. Here we explain why some websites insist on double-checking your departure, and what you can do to stop them. Also see: Which is the best web browser for Windows? 

A reader wrote into Helproom with the following question: "Sometimes when browsing the internet I come across pages which simply don’t want to go away. Instead, when I try to close the page or tab, I get a pop up saying “Are you sure you want to leave the page?” with the option to click to leave or stay on the page. I can see no reason for this behaviour other than to annoy me or trap me into staying on their site for even longer. Is there a way I can disable this feature?" 

This is how we solved their problem: Although the situation you describe can be very annoying, the reasoning behind this feature is sound. Consider a site where you’re typing in a large amount of text, such as an email or filling in a long form. It could be even more annoying to inadvertently close the window with a single click and lose all of your typing. In this case, the feature gives you a chance to go back and submit or save your work before losing it, forever. For this reason, you should think carefully about disabling this feature.  

The pop-up message is generated by JavaScript code embedded in the web page, so if you’re sure you want to disable it, you’ll need to prevent the underlying JavaScript code from running. The easiest, and crudest, way of achieving this is to disable JavaScript entirely.  

In Firefox, type about:config into the address bar and hit Enter. Next, click on the button to promise to be careful. Search on this page for javascript.enabled and click the Toggle button to disable JavaScript. To re-enable JavaScript, repeat the process. 

In Google Chrome, type chrome:://settings/content into the address bar and hit Enter. Scroll down to the JavaScript section and click ‘Do not allow any site to run JavaScript’. If you’d like to enable or disable JavaScript on a site-by-site basis, you can click the manage exceptions button and set up rules based on partial URLs.  

In Internet Explorer, click on the gear wheel icon at the top right and select Internet options from the menu. Now, select the Security tab and click the ‘Custom level…’ button. Scroll down to Scripting, then under Active Scripting, click disable to turn off JavaScript. Then click OK. 

Not solved your problem? Ask for advice in our Helproom forum.