Created
July 19, 2013 07:25
-
-
Save StuPig/6037332 to your computer and use it in GitHub Desktop.
detect and use localStorage
This file contains hidden or 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
| // Feature detect + local reference | |
| var storage, | |
| fail, | |
| uid; | |
| try { | |
| uid = new Date; | |
| (storage = window.localStorage).setItem(uid, uid); | |
| fail = storage.getItem(uid) != uid; | |
| storage.removeItem(uid); | |
| fail && (storage = false); | |
| } catch(e) {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment