0

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

treeseal7
  • 739
  • 8
  • 22

3 Answers3

0

Javascript does allow for this...

https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage

Other domains cannot read your domains local storage.

Shawn K
  • 779
  • 5
  • 13
0

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');
Community
  • 1
  • 1
Ali
  • 633
  • 1
  • 9
  • 20
  • Sorry, should have mentioned - it needs to be cross browser compatible, so local storage wouldn't work.. – treeseal7 Apr 25 '17 at 23:31
0

You should check localStorage polyfill: https://github.com/mortzdk/localStorage

This polyfill uses Flash for old browsers and native localStorage for new browsers.

Slawa Eremin
  • 5,264
  • 18
  • 28