Cookies-enabled Exit Intent Popup Box In Vanilla JavaScript

Category: Javascript , Modal & Popup | July 7, 2021
Views Total:946 views
Official Page:Go to website
Last Update:July 7, 2021


Cookies-enabled Exit Intent Popup Box In Vanilla JavaScript


A tiny exit intent popup library that displays a popup box when visitors are going to leave the current page.

The library tracks mousemovent events and reveals the popup box when the cursor moves out from the current viewport.

To provides a better UX, it uses cookies to prevent the popup from opening on the next visit.

See Also:

How to use it:

1. Load the necessary popup.css and popup.js files in the document.

<link rel="stylesheet" href="popup.css" />
<script src="popup.js"></script>

2. Load the CookieService.js for cookie support.

<script src="CookieService.js"></script>

3. Add any content to the exit intent popup. That’s it.

<div class="exit-intent-popup">
  <div class="newsletter">
    <b>Want to get updates to your mailbox?</b>
    <p>Subscribe to our newsletter!</p>
    <input type="email" placeholder="Your email address" class="email" />
    <button class="submit">Receive Newsletter</button>
    <span class="close">x</span>

You Might Be Interested In:

Leave a Reply