0

When I write code, I do so for my own amusement. I don't upload to a server or have my own website. I recently wrote a code which has quite a long run time (on average) and was just wondering if there's any way I can locally store a variable or two, without the use of cookies or other methods for storing info on a server. For example:

// On first run, declare variable
var rise=0;
// Do something with it when the page is open
setInterval('rise++;',10);
// And then store the value somehow when I close the browser
browser.onClose(locallyStore('keyname',rise));

So that when I refresh the page or come back to it another day, the old value will be plugged back in and it will continue running from where I left off...

Thnx!

LeiMagnus
  • 253
  • 2
  • 13

3 Answers3

0

If you are working under Windows, you may want to consider an HTA file.

These are basicly web-pages that run with application level access and can do some amazing things.

In this answer I cover how to read and write local files.

Community
  • 1
  • 1
Jeremy J Starcher
  • 23,369
  • 6
  • 54
  • 74
0

localStorage.keyname = rise;

Later...

var rise = localStorage.keyname;

In any modern browser. (IE9+ if I recall correctly).

jraede
  • 6,846
  • 5
  • 29
  • 32
0

Try

localStorage.setItem("key", "value");

$var myItem = localStorage.getItem("key", "value");
VF_
  • 2,627
  • 17
  • 17