<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Example</title></head><body><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><script> var dontShowUntil = new Date(new Date().getTime() + 60 * 60 * 24 * 1000); document.getElementById("close_ads").addEventListener("click", function () { localStorage.dontShowUntil = dontShowUntil; document.getElementById('ads_box').style.display = 'none'; }); if (new Date(localStorage.dontShowUntil) > new Date()) { document.getElementById('ads_box').style.display = 'none'; }</script></body></html>
↧
Answer by Zawiszor for How to set a cache with Local Storage
↧