Created
April 17, 2012 16:33
-
-
Save Victa/2407337 to your computer and use it in GitHub Desktop.
Detect private browsing mode in mobile Safari on iOS5
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
| var testKey = 'qeTest', storage = window.sessionStorage; | |
| try { | |
| // Try and catch quota exceeded errors | |
| storage.setItem(testKey, '1'); | |
| storage.removeItem(testKey); | |
| } catch (error) { | |
| if (error.code === DOMException.QUOTA_EXCEEDED_ERR && storage.length === 0) | |
| alert('Hello, private browser.'); | |
| else throw error; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment