javascript - Limit JS event to once per day per user -


i hoping limit event below once day per user. shadowbox appears when user tries leave page. don't want annoy user every time mouse leaves body, should happen first time on site each day.

$('body').one('mouseleave', function() {     $('.shadowbox').fadein(400) }); 

i have been advised using cookie way this, inexperienced in using cookies. thank you!

you can set cookie in function expiry.

good documentation available on here.

basically, check , set in function.

$('body').one('mouseleave', function() {     var cookie = document.cookie; //you need find cookie need here (if exists, don't anything)     return; //if exists     $('.shadowbox').fadein(400)     document.cookie = "mycookiename=true; expires=(datetime + 1day)" }); 

that way, fade , setting if there isn't cookie available.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

asp.net core mvc - How important is the global.json and src folder? -

c++ - Using Gtest how return different values in ON_CALL? -