HTML5 Localstorage JS
/* HTML5 SessionStorage * // Add the data function SSsetVal (key, val) {if (window. sessionStorage) {// check whether the user enters the key if (key = ''| val ='') {return 0;} sessionStorage. setItem (key, val); alert ('data: '+ key +'-> '+ val +' added successfully '); return 1 ;} else {alert ('local storage not supported '); return 0 ;}// query the specified data function SSgetVal (key) {// check whether the user has entered the key if (key = '') {return 0;} if (window. sessionStorage) {return sessionStorage. getItem (key) ;}else {return 0 ;}// modify the function SSchgVal (key, val) {if (window. sessionStorage) {// check whether the user enters the key if (key = ''| val ='') {return 0;} sessionStorage. setItem (key, val); alert ('data: '+ key +'-> '+ val + 'Modified successfully'); return 1 ;}else {return 0 ;}} // Delete the specified data function SSdelVal (key) {// check whether the user enters the key if (key = '') {return 0;} if (window. sessionStorage) {sessionStorage. removeItem (key); return 1 ;}else {return 0 ;}// traverses all functions SSgetAll () {if (window. sessionStorage) {// checks whether data exists if (sessionStorage. length = 0) {return 0;} var arrKey = new Array () // traverse data for (var I = 0; I
/* HTML5 LocalStorage * // Add the data function LSsetVal (key, val) {if (window. localStorage) {// check whether the user has entered the key if (key = ''| val ='') {return 0;} localStorage. setItem (key, val); showModel ('added successfully'); return 1 ;}else {return 0 ;}// query the specified data function LSgetVal (key) {// check whether the user has entered the key if (key = '') {return 0;} if (window. localStorage) {if (localStorage. getItem (key) {return localStorage. getItem (key) ;}else return 0 ;}else {return 0 ;}// modify the formulated data function LSchgVal (key, val) {if (window. localStorage) {// check whether the user has entered the key if (key = ''| val ='') {return 0;} localStorage. setItem (key, val); return 1 ;}else {return 0 ;}// Delete the specified data function LSdelVal (key) {// check whether the user has entered the key if (key = '') {return 0;} if (window. localStorage) {localStorage. removeItem (key); return 1 ;}else {return 0 ;}// traverse all functions LSgetAll () {if (window. localStorage) {// check whether there is data if (localStorage. length = 0) {// alert ('no items in the current shopping cart; add them now '); return 0;} var arrKey = new Array (); // traverse data for (var I = 0; I