i want to highlight new posts since the user's last visit, just as it is explained here:
How to highlight new items on the site since last visit with jquery?
i use this jquery to filter the links i want to highlight - it works perfectly fine
$(".itemlink").filter(function() {
return $(this).attr("data-timestamp") > $.cookie("last_visit");
}).addClass('highlight');
but i don't know when is the right time to set the "last-visit" cookie.
so far, i tried this:
$(window).unload(function(){
$.cookie("last_visit", $.now());
});
it does quite what i expected it would - sadly if the page is refreshed, of course that is an "unload" event as well... so when i refresh the page, i won't see any highlighted elements, because the "last-visit" cookie reads $.now()
any good ideas for a better time/way to set the "last-visit" cookie?