Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Store data locally using HTML and JavaScript

I have a small LAN with some computers.

I'm looking for a way to build a dynamic HTML webpage that uses JavaScript to store some data locally (can't use server side - only client side).

The webpage will be stored on a network drive shared with all the computers.

I wish to do that using a file, maybe an XML file or something similar that will be loaded using JavaScript and then saved again after some changes.

The data must be shared with all the computers on the LAN.

How can I do this?

like image 621
Amir Avatar asked Apr 02 '14 12:04

Amir


2 Answers

HTML5 localStorage

//Set
localStorage.setItem("lastname", "Smith");

//Get
var lastName = localStorage.getItem("lastname");
like image 86
h3li0s Avatar answered Sep 25 '22 08:09

h3li0s


You have the following options :

1.LocalStorage : You can store data in variables. There would be a limit as to how much data you can store.

Refer : http://en.wikipedia.org/wiki/Web_storage.

Eg:

// Store
localStorage.setItem("sample", "test");
// Retrieve
var sample = localStorage.getItem("sample");

2.WebSQL : This should be the most easy way of storing in client side. WebSQL is supported in almost all current browsers(HTML5). However there is no longer official support for WebSQL as its depreciated and no future updates.

Refer : http://en.wikipedia.org/wiki/Web_SQL_Database

3.IndexedDB : This is also another way to store data in local database. However this is not yet supported in all browsers.

4.XML

If you are going forward with storing data in local DB, then you can utilize PersistenceJS.

Refer : https://github.com/zefhemel/persistencejs

like image 30
Roy M J Avatar answered Sep 23 '22 08:09

Roy M J