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

javascript - How to process users in one specific order using map o each function? -

java - Two interface have same method name with different return type -

javascript - Linking from page A to a specific iframe on page B -