9

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?

4
  • Look for localStorage. A good start diveintohtml5.info/storage.html Commented Apr 2, 2014 at 12:16
  • 1
    JS can load and read XML files but can't write them on your disk. Commented Apr 2, 2014 at 12:18
  • 1
    @Satpal But what would happen if user clear cache? Commented Apr 2, 2014 at 12:18
  • Possible duplicate of Persist variables between page loads Commented Dec 10, 2018 at 9:22

6 Answers 6

15

HTML5 localStorage

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

//Get
var lastName = localStorage.getItem("lastname");
Sign up to request clarification or add additional context in comments.

1 Comment

Adding mozilla reference developer.mozilla.org/en-US/docs/Web/API/Storage/LocalStorage and that there is localStorage and SessionStorage, being the difference that SessionStorage cleans up after closing the window.
5

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

5 Comments

Thanks but I am looking for a way to make a shared DB over the LAN.. These methods work only for specific browser.
Without a server side is very difficult to share a local DB in a LAN from browser to browser.
Very difficult or impossible?
@Amir : You should probably set up a master system as server and using local IP connectivity, you can save the data to this system. It should be fairly easy provided you can set-up the server.
I'm not allowed to run a server on this LAN - that's my main issue
0

Try like this:

store a value :

localStorage.setItem("lastname", "amir");

get a value:

localStorage.getItem("lastname");

Comments

0

You can use HTML 5 LocalStorage

Comments

0

Depending on the flavor of data you're storing, simple cookies might work, accessed with plain old JS.

Comments

0

finally I found a solution for it! I am using a jQuery plugin called: twFile (http://jquery.tiddlywiki.org/twFile.html). It uses an activeX FileSystemObject - it works great on IE9.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.