I have a customer who wants to add one of those annoying JavaScript alerts that prevent users from closing a browser tab to make them a discount offer. You know, something like:

"are you sure you want to leave this page? Click on 'stay on this page' and you'll get a free [whatever]".

I'm pretty sure that trying to retain a user that already decided to leave is a bad idea, for many reasons. Some will stay, but many others will be really pissed off.

But actually, I found no research or published articles about this subject. I mean, real user research, with data, not just opinions.

Your opinions, help, sources, links to articles with user data (not just opinions) would be very useful.

EDIT: In my case, the customer is an online shop and they want to keep users browsing the website. We're not protecting unsaved data, just trying to keep people "in the shop". BUt we're talking about keeping people in although they already decided to go out.

EDIT: Thanks everybody for taking the time to reply. So many answers, and so much common sense in your replies. Thanks a lot.

  • 4
    In google docs for instance, if something is still being saved to the cloud in the background and you try and close the browser, then you will get a warning pop up asking if you're sure you want to leave. This along with the point made above are the only times this should be done from a UX perspective.
    – Sherlock
    Commented Oct 2, 2013 at 13:30
  • 44
    This behaviour can be adopted in instances where the reason is to protect the user, eg. from undesired loss of data. Not to support some promotional self interest, then it's very unjustified and will be an annoyance to any visitor. Commented Oct 2, 2013 at 13:41
  • 7
    While a confirmation when edits are pending is an exception, any site that does what is described earns an alt+f4 from me. This is bad behavior and there is no reason to assume that the action described in the popup has anything to do with the action performed upon confirm and is to be considered armed and dangerous. Additionally, there is little reason to presume that the popup is not injected by an advertisement.
    – horatio
    Commented Oct 2, 2013 at 17:00
  • 10
    Personally, I find that almost every question that starts off "how do I prevent users from..." touches a whole set of nerves... :-)
    – RBerteig
    Commented Oct 2, 2013 at 18:21
  • 6
    When a website prevents me from closing the tab for promotional purposes, I make a mental note to never visit that site again.
    – Kai
    Commented Oct 3, 2013 at 9:53

14 Answers 14


Depends why I was on that page. Stack Exchange sites have that warning, which I appreciate because I may have a half-typed answer left in a tab when I try to close the browser. If it's just begging/bribing me to stay, then I think it would annoy.

  • 14
    +1 In some browsers, hitting the backspace key causes the browser to navigate to the previous page, possibly causing half-typed text in a form to be lost. I appreciate confirmations in that case. Commented Oct 2, 2013 at 17:38
  • 7
    -1 - The OP specifically asked for research.
    – Kevin
    Commented Oct 3, 2013 at 2:47
  • 6
    @Kevin "Your opinions, help, sources, links to articles with user data (not just opinions) would be very useful.". I interpret that as: he wants our opinions, but not links to articles with only opinions. Commented Oct 3, 2013 at 6:32
  • 2
    AndSoYouCode is right, @Kevin, I appreciate your opinions, it just happens that Internet is plagued by articles that claim to be research-backed, but they are just opinions with no data. This is what I want to avoid. Commented Oct 3, 2013 at 9:00
  • 1
    I fear that this answer has so many upvotes only because Stackexchange users agree with this opinion, which might is not true for a lot of other users.
    – Uooo
    Commented Oct 4, 2013 at 8:43

Forcing the user to do anything creates a User Experience that can feel desperate and low rent. There are many sites that will use any trick available to hook the customer - the question is do you want to work on a site like that?

It's a moral issue more than a UX one.

  • 21
    Most designers have to deal with marketing/CR/management -people who want to add noise and bad UX elements to a UI to fulfil their own agenda. It's our job as designers and experience planners to distinguish the good ideas from the bad ideas using our know-how in the field. Bad ideas are not isolated to companies with a questionable morality. Commented Oct 2, 2013 at 11:42
  • I agree it's not limited to companies. Explaining why something is a bad idea well is a fine art and, even for the best, clients or a stakeholder can be adamant about what they want. In the cases where bad or 'low rent' solutions are forced through it is down to an individual UX person if they can live with that compromise. A 'bad' idea might increase sales in a way that that company wants, often at the expense of long term customer satisfaction. Commented Oct 2, 2013 at 15:12
  • 2
    -1 - The OP specifically asked for research.
    – Kevin
    Commented Oct 3, 2013 at 2:48
  • 3
    @Kevin No, he asked for "opinions, help, sources, links to articles with user data"
    – Svish
    Commented Oct 3, 2013 at 8:08
  • 1
    @Svish + "(not just opinions)" Commented Oct 3, 2013 at 10:54

Subscription popups that appear when a page is loaded are easily annoying, but may not necessarily affect bounce rates negatively.

However, the most important factor to consider when working with any kind of forced functionality is that it will come loaded with negative connotations. Users tend to criticize advertisements not because of their very existence, but because of the nature that they are presented (Bauer and Greyser 1968; Ducoffe 1996; Sandage and Leckenby 1980). In this way, although your warning might, in some instances, keep users on the site, it will almost always come unwanted.

All in all, the more I return to the first link I posted here, the more the popup ad dissuades me from ever wanting to return again.

Additionally, a key difference between popups-on-enter and popups-on-exit are that the latter prevent the user from executing a deliberate, wanted action. Consider that hiding the close button might keep the user on the site, but would not compel them to return.

  • 4
    there is a difference between a popup when you arrive and a popup preventing/delaying you from leaving.
    – Mr.Mindor
    Commented Oct 2, 2013 at 16:43
  • 1
    I agree - I mean to play devil's advocate by claiming that some popup functionality does help, while at the same time, all kinds of popups are unadvisable. Although popups-on-enter have not been shown to dissuade users from staying on the site, research has demonstrated that popups are generally described as irritating. Commented Oct 2, 2013 at 16:52
  • While both entrance and exit popovers as either ads, datagrabs, or pointless are you sure you want to leave nags annoy me; I find the former more objectionable because they interrupt/delay what I'm at the site to do. In most cases I just dismiss the exit nag to complete closing the tab; one at the start is much more likely to result in my adding a new adblock rule so that in the future I can get directly to what I'm trying to do. Commented Oct 2, 2013 at 17:48
  • 1
    There is a "bargins" site my wife frequents and occasionally sends me links to. It refuses to show the linked product page without creating an account and logging in. That might be excusable, except that it does it in a pop-over, with the most of the content dimmed behind. The impression I get is one of being taunted, and I don't find that to be an effective sales tactic. I close the window instead.
    – RBerteig
    Commented Oct 2, 2013 at 18:25
  • 1
    It's my personal opinion that popup functionality should never ever be used, but I wanted to provide some hard information about the pros and cons. My argument is that, even if your popup is successful in its purpose, it offends the user in doing so. I updated that idea by bolding it. Commented Oct 2, 2013 at 19:39

It may sound strange but was once led by this type of intrusive message. I was searching for online data host service, and after looking at the suggested plans I clicked the back button. The message appeared giving me a better suggestion for a plan, and it happened that I took it.

The lesson learned here is to recognize the user intention. For example, you can set a timer measuring how much time the user was on the page before popping-up the offer message. If it's less than 30 seconds - don't pop it up. But in case the user reviewed the plans well for more than a minute than there may be a chance he is interested, suggesting a better price might get the sale.

So I'm not totally against it, but it should go according to proper context.

  • +1 for great example. It looks like a real chaffer between persons and the salesman's last proposition. Commented Oct 3, 2013 at 7:42
  • 2
    But would it not have been a better experience if the better plan had been suggested to you in the first place?
    – calum_b
    Commented Oct 3, 2013 at 14:14
  • I agree with scottishwildcat. If you are able to give better information when a user already decided to leave, then you should really think about your presentation on the website. The interesting information should be there from the beginning, and the content should just make the user want to stay.
    – poke
    Commented Oct 4, 2013 at 4:13

I would tackle the problem the other way round: Don't make the users want to leave in the first place.

When users visit a webpage, they have a goal. Some look for information. Some want to buy products. Some want to compare prices. Some look for a possibility to contact the company, etc.

Showing an Alert with a discount offer when the user wants to leave seems a bad idea because:

  • You don't know if the user wanted to buy something.
  • Why should only users, who indicate to leave, get a special offer?

If your goal is that your users buy something, you could do:

  • Give every user a free goodie, or a discount, for their first order
  • Make the site more user-friendly (easier to find products)

There maybe are other possibilities depending on your company.

  • @martinf why not? The question asked is "Preventing users from closing browser tab. Bad idea?" and this answer contains "Showing an Alert with a discount offer when the user wants to leave seems a bad idea because..."
    – Uooo
    Commented Apr 3, 2014 at 4:36
  • ok, sorry, my bad
    – Martin F
    Commented Apr 3, 2014 at 17:48

Let's try bringing this back to basic emotions:

It's a reasonably safe statement to say people don't like being blocked from doing something. It doesn't matter whether you're on a website or in a physical store. When you want to leave and something gets in your way, then the action of being blocked has a negative effect.

I had a thought that there may be a variation on the exit popup: detecting that the user is about to leave (maybe!) and show a popup before they actually click to close or click the back button. There's a demo of this. Hmmm, ok it's a lacklustre implementation, especially since it keeps coming up rather than a one-off show - but being blocked on the way to the exit is not feeling any better is it?

So - once users have made up their mind to leave, whether they have clicked the close button already or are on the way to doing it, the fact is that users have already made a decision about the site and want to leave. It's very very hard to switch a decision around from a deep negative to a positive. The best you could hope for is a disgruntled purchase.

For this reason, tempting users with an offer or a discount code via an exit popup is simply the wrong way to engage customers. It's far better to engage with them before they reach the negative feeling of wanting to leave.

I have come across situations where popups (not at exit) have worked well but the environment needs to be right and the execution needs to be well thought out:

  • the perception of the site already needs to be one of good reputation - a popup on a website that is already annoying users is only going to compound the negativity
  • the design of the popup needs to be in context of the design of the rest of the page
  • the user needs not to be in the middle of a task (so browsing is ok and in the middle of zooming into a product is bad)
  • the popup needs not to appear too soon - nor too late
  • the copy on the popup needs to be sensitive and well thought out
  • the popup needs not to appear too often on repeated visits
  • the popup needs to appeal to basic emotions such as scarcity or fear of loss - so users feel they are special or lucky to see the popup, and also take not of the details for fear of not seeing it again or losing/forgetting the discount code
  • the popup should be shown when users seem to be taking some time to consider something rather than flicking around erratically. You can detect different behaviours by frequency of flicks and speed of mouse movements etc
  • waiting too long to show the popup is bad as it starts to approach the 'popup at exit' mentality. Users are far from stupid and will quickly turn from feeling they are lucky to knowing that an attempt is being made to try and keep them on the site.
  • it may be effective to defer the popup to a return visit, further promoting the scarcity emotion whilst not detracting from a first browsing experience. If a user returns, they are already in a positive or receptive state.

Unfortunately, very few implementations take the care and consideration to design in all these features, and I have only seen one that has done it all, and it was such a positive experience that I immediately scribbled down the discount code and shared it with my partner, and it probably doubled my purchase - largely because of the appeal to basic emotions I mentioned above - scarcity and fear of loss.

A disadvantage of using popups at all:

Using discount codes in popups, if done well, may be a great short term boost to sales. However, I do question the (hard to research) longer term effect.

Since my own positive experience with a popup above, when I return to the site, I sometimes delete all the cookies on that site to try and see if it makes the popup appear again. Then I'm frustrated that I can't get it to show, and maybe I won't buy from them again until the popup appears again because I know I can get a discount sometimes.

So while clever tactics may be used to show a popup successfully once, then not understanding the rules clearly about how, why and when the popup appeared can also lead to confusion, doubt, negativity, and a feeling that the site should just be more open and consistent with all visitors in the first place!

It is worth mentioning that just because something may be generally accepted as a poor UX practice, doesn't prevent a decent and well executed implementation of a feature from increasing conversion rate, and for many businesses that is the main goal. Vistaprint presented some research to the UPA Boston conference in 2012 which laid out real A/B testing results vs UX best practices and expert opinions [slideshare].

Not all tests resulted in winning changes, but many did. Whilst they didn't play with exit popups (as far as I know), they do make valid and relevant points:

  • best practices are only general
  • a/b testing is critical
  • context and relevance matters
  • small changes can make a difference
  • nothing is straightforward
  • there's a balance between standardization and innovation
  • continue to optimize
  • it depends

I've noticed on Twitter's web site that if I write text into the new tweet composition field and then close the window/tab without posting the tweet, the field is re-populated with that text automatically if I go back to Twitter. I think this is far better UX than annoying or scaring the user with an alert, and given a fairly straightforward form, would be fairly easy to implement with HTML5's localStorage mechanism. (I implemented this myself on my regex testing/Backbone.js playground site, Now you have two problems, with code available.)


The only acceptable reason to block navigation is to protect the user from losing data. Forms that are half filled, files half uploaded, posts half written - in those cases this is actually helpful, as it protects the user if they accidentally close the browser or tab.

However using it to try to prevent the customer from leaving? Not only is this bad UX, but this is a poor business practice. Now if there is some kind of shopping cart that will not persist after the session (no account, no cookies, no localstorage) then it would be valid to warn them that closing the window will erase the cart. And it may be acceptable to also offer them some incentive to remain - but only if there is an actual risk of data loss.


Perhaps take a step back and see if the application can fit its environment better.

As I interpret him, Alan Cooper prescribes that the user should never have to hit Save (or Cancel); applications should update continuously, defer validity checking to the last possible minute, and have excellent auditing and rollback.

Assume the that normal case is that all changes are valid. Either save each change as it happens, or as the user leaves that UI control, or at the least, save it when you detect the user leaving the page (i.e. in lieu of forcing them to decide).

I am in favor of adding non-modal validity messaging as the user changes values rather than having validity issue be a surprise at the end, but I agree with Mr. Cooper that the application, not the user, should deal with the issues of partial data.

So rather than pondering whether you should "allow" the user to close a tab, make an application that does not care if or when they do.


Your question is looking for "research or published articles about this subject" A very noble goal, you have several answers here offer opinions and nothing concrete. You say you looked and did not find anything, given the subject it is difficult to imagine how any reliable data could be collected.

There would only be two possible sources.

  1. User completed survey
  2. Comparison of unique users across multiple sites and business

User Surveys from users who are “really pissed off” are unlikely to be completed, or helpful if they are.

Pretty sure you are going to have difficulty getting to different business with similar enough business models and differing appreciations for their customers, to allow you track and report their customer return rate to compare with their main competitor.

Looks like common sense is going to be the only reliable source for the answer to your question


You're asking for published research on a topic that maybe nobody's bothered to research, maybe because it has a common-sense answer.

If you want research results, then do your own. Just run a few quick usability tests on the site using tasks that include closing the tab. Your customer might be more convinced by your own findings (with actual quotes and/or video clips) than by a published study.


Having a popup to offer a discount before a purchaser leaves is great. You've propably got IT guys answering this question instead of sales people. I do this regularly for clients and get between a 15 - 25% increase in sales beacuse of it. I only set the popup if they want to close the website, and make sure the offer is attractive enough to purchase. I also only have it on the first page of the sales funnel - Just do it!

  • -1 This answer does not seem to have the interests of the user at heart. In the long run, annoying or offending your users will harm your company even if such a technique causes a short-term spike in sales. Commented Jan 30, 2014 at 23:58
  • @GrahamHerrli offering the user a discount is not harmful. Commented Oct 9, 2016 at 18:22

You seem to intuitively know the answer, but want some statistics to back you up. I'm not sure where you would find such 'reseach' or how accurate it could be, without actually knowing directly what the visitors felt, including the ones too pissed off to reply to a survey, but think about what you are doing for a minute. You are literally taking control of the user's PC. This behavior is virtually indistinguishable from a virus, and that was the first thing I thought when I first encountered it. The worst is when the popup reappears every time you try to close the window, basically forcing you to keep that window open. Honestly, that is an automatic task master close from me. And I would never EVER buy anything from such a website, or ever visit it again. Another poster said that its not that bad, because hacker javascript could just do bad things without the popup, but think about the nature of the popup, a suspect website is asking me to click 'ok' on a popup, and I'm not OK with that, EVER. I actually came to this website to see if this was a common virus vector. I know this thread is 3 years old, but since information about this is so limited, maybe this post can let another designer know never to do this.


In technical terms, we are talking about the beforeunload event.

Thankfully, starting with Firefox 4, Chrome 51, Opera 38 and Safari 9.1, a generic string not under the control of the webpage is shown (if there is a listener to that event, which returns a certain value). For example, Firefox displays:

This page is asking you to confirm that you want to leave – data you have entered may not be saved.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.