Quantcast
Channel: How to set a cache with Local Storage - Stack Overflow
Viewing all articles
Browse latest Browse all 4

How to set a cache with Local Storage

$
0
0

I have a ads box and i want close it to by clicking x button so after it has been closed i don't want to se it until 24 hours with cache I created a localstorage but it's not working as i expected how should i edit my example

    var showCase = Math.round(+new Date() / 1000);        document.getElementById("close_ads").addEventListener("click", function () {        if (typeof localStorage.showCase == 'undefined' || parseInt(localStorage.showCase) <= (showCase - 3600)) {                      localStorage.showCase = showCase;          document.getElementById('reklam_box').style.display = 'none';        }        });
<div id="ads_box">Hi..I am a ads..<span id="close_ads">Close ads and don't show unit for 24 hours</span></div>

Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images