Saving in JavaScript module

I need to write a JavaScript module that rotates banner images displayed in a SharePoint web part. I would like to rely as little as possible on the SharePoint APIs and maximize my support in the JavaScript module that controls the web part. I would like to track the last time my code went to the next image in the list, and what that image was. The list itself will be stored in SharePoint and accessible through the REST API.

So, in the modern JavaScript browser runtime, are there any means of locally saving the small record described above?

+1
source share
1 answer

There are several 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) { /* ... */} 
+1
source

Source: https://habr.com/ru/post/979324/


All Articles