Local Storage HTML5 Wrapper


/ Published in: JavaScript



Copy this code and paste it in your HTML
  1. /*
  2.  * This Datalton object can be used to store strings or objects.
  3.  */
  4. var Datalton = function(){
  5. //private code
  6. if (typeof(localStorage) == 'undefined' ) {
  7. return false;
  8. }
  9. //public
  10. return {
  11. set:function(prop, val){
  12. localStorage.setItem(prop, JSON.stringify(val));
  13. },
  14. get:function(prop){
  15. return JSON.parse(localStorage.getItem(prop));
  16. },
  17. remove:function(prop){
  18. localStorage.removeItem(prop);
  19. }
  20. }
  21. }();

URL: www.digitalsurgeons.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.