Search code examples
javascriptbrowsersaveprogress

How can I step by step save my progress with Javascript? (in a Browser)


I've wrote a programm for the console of my browser.

If it's done it returns a result, that I want to save in some way. Afterwards I need to progress some steps in browser manually (the programm isn't running anymore). And the programm runs again and again return a result.

Is there some way to store the combined result?

At the end I always want to return something like:

return storedResults + currentResult;

Solution

  • If you need to store result of your console applications you can use the Web Storage API.

    The Web Storage API provides mechanisms by which browsers can securely store key/value pairs, in a much more intuitive fashion than using cookies.

    Save result (three different way to do It):

    localStorage.result = 'OK';
    localStorage['result'] = 'OK';
    localStorage.setItem('result', 'OK');
    

    View result:

    console.log(localStorage.result); // print "OK"
    

    See complete reference.