My jquerymobile App requires the use of localStorage and sessionstorage e.t.c, I've been giving a prompt to users without cookie support and telling them to enable cookies, but if a user has private browsing enable, this create cookie test I'm doing doesn't work and they just get a still erroneous screen, does anyone know how I could test if the user has private browsing enabled?
Thanks
I don't have an Iphone to test this on, but in the desktop Safari browser (in private mode) running the below function does catch the error and handles it as expected.
function storageEnabled() {
try {
localStorage.setItem("__test", "data");
} catch (e) {
if (/QUOTA_?EXCEEDED/i.test(e.name)) {
return false;
}
}
return true;
}
if (!storageEnabled()) alert('localStorage not enabled');
Jsfiddle: http://jsfiddle.net/B9eZ5/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With