Javascript to show popup window when user moves mouse up fast to the top trying to close / leave this web page

1 Bitcoin bounty has been announced by author.
0 has been already awarded by author.
1 remains available.

I've seen this clever marketing tactic on many websites - when I am about to leave their website and move my mouse up fast to the top of the screen (to close their tab in Chrome, etc), the site reacts real fast, showing me some large modal window with "subscribe" email capturing form, or with "special offer" .

The timing is really good, and I usually stop for a second to decide on that modal window. I do it almost unconsciously, and so I would bet that this tactic increases conversion rates to whatever they are selling or grows their email list faster.

1) Here is one example of the webpage where I've experienced this behavior:

2) here is another site:

So the question is this - do you know of an existing jQuery plugin that does this or do you know how to do this in Javascript? Their script is very accurate and does not show you a modal on any random mouse up movement. It triggers only when you are really about to close their website. So it must be a combination of

  • certain period of time spent on the page (reading), or maybe even requiring user to scroll down past certain % of the webpage
  • then sudden fast and wide mouse up movement, and
  • crossing certain "invisible" bar at about 10% from the top of the physical browser window - at this point user has not yer reached "close tab" button, so there is still few milliseconds and hope to catch the users attention with the full-screen modal popup. Again, specific timing / height % here is very important and needs to be optimized by experiments

As you see, this script is probably more advanced than just few lines of code. So could anyone suggest an existing jQuery plugin that implements the popup when user move mouse trying to leave the page? Thanks!

1 Answer

Internet users could send Bitcoin Tips to you if they like your answer!

Here is an Open Source package called OuiBounce - it has all these features that you mention

and it is also available through Wordpress plugin wBounce:

The rest of this answer is less relevant but I am still leaving it here:

... I've found a WordPress plugin called SUMOME, they are using exactly the same trick

They describe it like this:

Catch Your Visitors Right before They Leave

List Builder’s Smart Mode technology detects the exact moment when a visitors is about to leave. Immediately, a beautiful lightbox pops up asking for the visitor’s email address.

They use their own plugin on their website, so if you would visit that link, read it for half minute, then try to leave, you would experience that popup box yourself.

If someone has some time to take a look into their <script> tags to figure it out, please post here!


Too many commands? Learning new syntax? is a free tool to save your favorite scripts and commands, then quickly find and copy-paste your commands with just few clicks.

Boost your productivity with!

Post Answer