Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function saveDataToDomStorage(name, data)
- {
- var jsonData;
- /*
- * DOM storage can't store complex data (object, array...)
- * We have to serialize the data in a simple format, JSON.
- *
- * We get a string standing for the complex object,
- * and store this string in the DOM storage.
- *
- * Complex data -> JSON stringify -> Simple data (string)
- */
- jsonData = JSON.stringify(data);
- window.localStorage.setItem(name, jsonData);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement