Skip to content

Instantly share code, notes, and snippets.

@kaskajp
Last active January 9, 2016 01:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaskajp/83bafb72359bace36013 to your computer and use it in GitHub Desktop.
Save kaskajp/83bafb72359bace36013 to your computer and use it in GitHub Desktop.
Test if localStorage is available
function localStorageTest(){
var test = 'test';
try {
localStorage.setItem(test, test);
localStorage.removeItem(test);
return true;
} catch(e) {
return false;
}
}
if(localStorageTest() === true){
// available
}
else {
// unavailable
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment