/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* * This Datalton object can be used to store strings or objects. */ var Datalton = function(){ //private code if (typeof(localStorage) == 'undefined' ) { return false; } //public return { set:function(prop, val){ localStorage.setItem(prop, JSON.stringify(val)); }, get:function(prop){ return JSON.parse(localStorage.getItem(prop)); }, remove:function(prop){ localStorage.removeItem(prop); } } }();