POPUP appears only once per user - Cookies

2

I have a POPUP on my site that appears whenever the person updates or enters it.

I want to create a javascript function (because the page is in HTML and you can not use PHP POPUP only once per user with an interval time, type 1 day for it to appear again.

I'll leave my code below:

<html>
<head>
<style>

#popup{     
margin-top: -45px;
    position: absolute;
    width: 300px;
    height: 250px;
    left: 400px;
    top: 288px;
    z-index: 99999;
    margin: -175px auto 0px 15px;
    border: 6px solid rgba(0, 165, 71, 0.13);
    padding: 10px;
    padding-left: 30px;
    padding-top: 30px;
    background: rgba(255, 255, 255, 0.96);}

.fechar {position: absolute; top: -10px; right: -10px;}
</style>
</head>

<body>

<script src='http://ajax.googleap...2/jquery.min.js' type='text/javascript'/></script> 

<div id='popup'>
    <div class='fechar'>
        <img src='http://jconlinedigit...e_fechar.png'/> 
    </div>
</div> 

<script type='text/javascript'>
    $(document).ready(function(){
       $('.fechar').hover(function(event){
             event.preventDefault();
              $("#popup").hide();
        });
    });  
    setTimeout(function() {
       $("#popup").css("display","block");
    }, 5000);    
</script> 

</body>
</html>
    
asked by anonymous 16.09.2015 / 13:21

1 answer

1

I made a very simple example of how to work with cookies saving if the user closes the modal and prevents it from opening again:

if ($.cookie('modal') != 'false') {
  $.cookie('modal', 'true');
}

if ($.cookie('modal') == 'true') {
  alert('modal open');
}

$('.close-modal').on('click', function() {
  $.cookie('modal', 'false');
});

Example complete here .

    
16.09.2015 / 14:07