Using HTML5 Local Storage in Your Web Apps

Using HTML5 Local Storage in Your Web Apps

Store a Value: window.localStorage.setItem(keyinput,valinput)

		var keyinput = “key10”;
		var valoutput = “value10”;
		if(typeof(window.localStorage) != 'undefined'){ 
			window.localStorage.setItem(keyinput,valinput); 
		} 
		else{ 
			throw "window.localStorage, not defined"; 
		}

Retrieve a Value: window.localStorage.getItem (keyinput);

		var valoutput ;
		if(typeof(window.localStorage) != 'undefined'){ 
			valoutput = window.localStorage.getItem (“key10”); 
		} 
		else{ 
			throw "window.localStorage, not defined"; 
		}

Remove a Value: window.localStorage.removeItem(keyinput);

		var valoutput ;
		if(typeof(window.localStorage) != 'undefined'){ 
			valoutput = window.localStorage. removeItem (“key10”); 
		} 
		else{ 
			throw "window.localStorage, not defined"; 
		}

Clear all the values: window.localStorage.clear()

		if(typeof(window.localStorage) != 'undefined'){ 
			window.localStorage. clear() ;
		} 
		else{ 
			throw "window.localStorage, not defined"; 
		}

Sample Code: l

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s