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, the object seems to be 'empty'. How can I pass the object between one page to another?
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.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.