I'm making a local web app to be used offline and need a way of 'saving' data locally and also being able to read it. I know javascript doesn't really allow for this except in a sandboxed way. What would be the best way to go about this.
Can I set up a local sever database to store and load the data?
The solution ideally needs to be cross browser compatible, so 'local storage' wouldn't be an option.
thanks
Javascript does allow for this...
https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
Other domains cannot read your domains local storage.
You will need to use html5 localstorage. Take a look at this link for more information Storing Objects in HTML5 localStorage
const someData = { 'a': 0, 'b': 1};
//add to local storage
localStorage.setItem('data', JSON.stringify(someData));
// Retrieve from storage
const retrievedObject = localStorage.getItem('data');
You should check localStorage polyfill: https://github.com/mortzdk/localStorage
This polyfill uses Flash for old browsers and native localStorage for new browsers.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.