jquery store array localstorage or cookie -


i want store array in order use after refresh page browser or history forward (if website in history).

this array important me because contains history urls of visited website pages. allows me detect , forward browser buttons.

for example i've got history_url_array = [];, how can store in local or in cookie easly , compatible html4 , html5 without plugin script?

i success kind of thing variable : self.name= window.location.pathname;

sorry english, i'm french...

to set array (in case history_url_array) in localstorage, use

localstorage["history"] = json.stringify(history_url_array) 

on page refresh, array localstorage,

var history = json.parse(localstorage["history"]) 

but mind browser support. ie has been shaky in support html 5 components. here's support table :

enter image description here

anyway better run function before start using localstorage.

function supports_html5_storage() {   try {     return 'localstorage' in window && window['localstorage'] !== null;   } catch (e) {     return false;   } } 

if function returns true can insert [] in localstorage, else, you'll have store in database or server session storage.

for more info on localstorage, head on dive html5


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -