Last active
January 9, 2016 01:10
-
-
Save kaskajp/83bafb72359bace36013 to your computer and use it in GitHub Desktop.
Test if localStorage is available
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
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