0

Really need your help here. I would like to have a timer for content in localStorage.

For example I have got a dynamically updated DIV

<div id="news"><p>test</p></div>

And managed to add it as html block to localStorage by using this code:

$(function() {
 localStorage["homeNews"] = JSON.stringify($("#news").html());
});
$(function() {
 if (localStorage["homeNews"] != null) {
   var contentsOfNews = JSON.parse(localStorage["homeNews"]);    
  $("#news").html(contentsOfNews);
} 
});

There is an example but it doesn't seem work for some reason: http://jsfiddle.net/Rn4NC/4/

qqruza
  • 1,385
  • 4
  • 20
  • 41
  • How do you know it is not working? I fiddled with your example and it seems to do what you told it to do.. – Shimon Rachlenko Sep 17 '13 at 14:44
  • I am using Chrome on Mac and it doesn't save LocalStorage for the time mentioned in the script...Every single time I am refreshing the page it adds the content of the div to the localstorage... – qqruza Sep 17 '13 at 15:05

0 Answers0