How to detect users on iPhone with Private Browsing enabled?

My jquerymobile application requires the use of localStorage and sessionstorage, etc., I suggest users without cookie support and tell them that they allow the use of cookies, but if the user has access to a closed browser, this will create a test cookie. it doesn’t work, and they just get another erroneous screen, does anyone know how I can check if user view is turned on?

thanks

+7
source share
1 answer

I don’t have an Iphone to check this out, but on the desktop the Safari browser (in private mode), which executes the function below, detects an error and processes 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/

+10
source

All Articles