Created
October 1, 2010 19:21
-
-
Save danesparza/606702 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// First, make sure our browser supports HTML 5 local storage | |
if (typeof(localStorage) == 'undefined' ) | |
{ | |
alert('Your browser does not support HTML5 localStorage. Try upgrading.'); | |
} | |
else | |
{ | |
try | |
{ | |
// saves to the database using key/value | |
localStorage.setItem('name', 'Hello World!'); | |
} | |
catch (e) | |
{ | |
if (e == QUOTA_EXCEEDED_ERR) | |
{ | |
// data wasn’t successfully saved due to quota exceed so throw an error | |
alert('Quota exceeded!'); | |
} | |
} | |
// Write out the item from local storage: | |
document.write(localStorage.getItem('name')); | |
//deletes the matching item from the database | |
localStorage.removeItem('name'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment