html5 - Javascript local storage error -
how can assign javascript variable local storage variable?
here attempt:
var abc=localstorage.crabc; function tab() { if (abc==2) { window.open("index.html","_self") } else { window.open("main.html","_self") } } tab() localstorage.crabc="2";
you need use localstorage.getitem()
, localstorage.setitem()
retrieve , store items localstorage:
var abc=localstorage.getitem('crabc'); function tab() { if (abc=='2') { window.open("index.html","_self") } else { window.open("main.html","_self") } } tab(); localstorage.setitem('crabc', '2');
Comments
Post a Comment