Code

Wait X before showing modal again

Automatically show a modal or div after X minutes once the window/element has been hidden/closed in Webflow. A great way of showing advertisements, alert messages and so forth based on a time interval between the last time it was viewed.

Wait X before showing modal again preview

Automatically show a modal or div after X minutes once the window/element has been hidden/closed in Webflow. A great way of showing advertisements, alert messages and so forth based on a time interval between the last time it was viewed.

How to add it

  1. Add the Javascript code to the closing body custom code section
  2. Update Javascript code based on your requirements and class names

The code

Javascript
                      <!-- Add to body close section -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>

<script>

// Change 30 to the number of minutes you want it to wait until the popup shows up again
// Change .preloader class to the class of your preloader container

var date = new Date();
var minutes = 30;
date.setTime(date.getTime() + (minutes * 60 * 1000));
            
$(document).ready(function() {
    if ($.cookie('noShowWelcome')) $('.preloader').hide();
    else {
       $.cookie('noShowWelcome', true, { expires: date });
    }
});

</script>

                    

Browse similar code snippets

Language

More from Timothy Ricks

Profile →

Similar code snippets

All code snippets →