Persistence In A JavaScript Module
I need to write a JavaScript module that rotates banner images displayed in a SharePoint web part. I would like to rely on SharePoint APIs as little as possible, and keep as much a
Solution 1:
There are a few ways. But, for something like this, I would go with localStorage. For instance:
localStorage.setItem('lastSlide', JSON.stringify({
time: +new Date,
src: 'http://lorempixel.com/100/100'
}));
// Then, to retrieve:
var lastSlide;
try {
lastSlide = JSON.parse(localStorage.getItem('lastSlide'));
} catch(e) { /* ... */}
Post a Comment for "Persistence In A JavaScript Module"