I am having some issues with JQuery and local storage. I have a div I want to display only once every 4hrs.
Currently, this is my code:
$(function() {
var now = (new Date()).getTime();
var lastTime = 0;
var lastTimeStr = localStorage['lastTime'];
if (lastTimeStr) lastTime = parseInt(lastTimeStr, 10);
if (now - lastTime > 24*60*60*1000) {
//START UP FADEOUT SCREEN
$('#startup').delay(1500).fadeOut(2000);
}
localStorage['lastTime'] = ""+now;
});
However, the fadeout no longer works.
Can anyone help me out with this one? Do I need some kind of plugin for localStorage?
Thanks
localStorageis not supported in IE < 8 though. What do you mean by "no longer works"?now - lastTime > 24*60*60*1000is false for the next 24 hours. You probably should putlocalStorage['lastTime'] = ""+now;inside theifstatement.