In a wordpress site I have a pop up window (for email capture) that is triggered by the "mouseleave" event.
The pop up works fine but Once the info is captured or the pop up window closed I dont want to bother the visitor with this pop up anymore. So I want to set a cookie which will detect that this event has already taken place and to not trigger again until a week or a month later for that visitor.
Here is the code:
<script>
    jQuery(document).ready(function() {
        jQuery('html').one("mouseleave", function(e){
            jQuery('.backdrop, .box').animate({'opacity': '.50'}, 300, 'linear');
            jQuery('.box, .box').animate({'opacity': '1.00'}, 300, 'linear');
            jQuery('.backdrop, .box').css('display', 'block');
            jQuery( this ).off( event );
            });
            jQuery('.close').click(function(){
                jQuery('.backdrop, .box').animate({'opacity': '0'}, 300, 'linear', function(){
                    jQuery('.backdrop, .box').css('display', 'none');
                    });
                });
                jQuery('.close').click(function(){
                    close_box();
                    });             
                jQuery('.backdrop').click(function(){
                    close_box();
                    });
    });
    function close_box()
    {
    jQuery('.backdrop, .box').animate({'opacity': '0'}, 300, 'linear', function(){
                    jQuery('.backdrop, .box').css('display', 'none');
    });
    }
</script>
Here is the HTML:
   <h1>THIS IS MY WEB PAGE </h1>
   <div class="backdrop"></div>
   <div class="box"><div class="close">X</div>
   <div class="box-content">
   THIS IS THE LIGHT BOX<br>
   <p>SOME INFO</p>
   </div>
   </div>
And this is the CSS:
.backdrop {
    position:absolute;
    top:0px;
    left:0px;
    width:100%;
    height:100%;
    background:#000;
    opacity:.0;
    filter:alpha(opacity=0);
    z-index:50;
    display:none;
    }
.box {
    position: fixed;
    top: 20%;
    left:30%;
    background: url("box-img.jpg") repeat scroll 0 0 #fff;
    z-index:51;
    padding:10px;
    -webkit-border-radius:5px;
    -moz-border-radius:5px;
    border-radius:5px;
    -moz-box-shadow:0px 0px 5px #444444;
    box-shadow:0px 0px 5px #444444;
    display:none;
    height: 650px;
    width: 600px;
    }
.close {
    float:right;
    margin-right:6px;
    cursor:pointer;
    }
How can I accomplish that?
 
     
    