Skip to content Skip to sidebar Skip to footer

Pass Javascript Objects Between Html Pages

I have made a class in javascript with an object that contains both variables and functions. I instantiate the object within one .html page, but when I change to another .html page

Solution 1:

You can have a look at Web Storage. This won't allow you to store a full JavaScript object, however you will be able to store as many string name-value pairs as you want. Either permanently (between browser restarts) or as part of a session.


Solution 2:

Use localStorage, check this lib: https://github.com/marcuswestin/store.js

You can do something like:

store.set('foo', originalObject);

and then...

var restoredObject = store.get('foo');

Removing stored objects:

store.remove('foo');

Fork "jQuery-like" syntax: http://pastebin.com/x3KpKyr1


Post a Comment for "Pass Javascript Objects Between Html Pages"