Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if ios is using private browsing

One of my jquery plugins is having issues, and the issue occurs when private browsing is turned on in ios.

Is there a way to check this?

like image 962
user759235 Avatar asked Dec 03 '22 01:12

user759235


1 Answers

In private mode user can't use local storage try this:

var storageTestKey = 'sTest',
    storage = window.sessionStorage;

try {
  storage.setItem(storageTestKey, 'test');
  storage.removeItem(storageTestKey);
} catch (e) {
  if (e.code === DOMException.QUOTA_EXCEEDED_ERR && storage.length === 0) {
    // private mode
  } else {
    throw e;
  }
}
like image 145
anton_byrna Avatar answered Dec 14 '22 11:12

anton_byrna