Iphone localStorage “QUOTA_EXCEEDED_ERR” issue

前端 未结 5 1980
孤街浪徒
孤街浪徒 2020-12-30 02:19

I trying to use Client Side Storage available in HTML5 (localStorage) for Iphone Application , and I\'m completely aware of the \"QUOTA\" associated for loc

5条回答
  •  清酒与你
    2020-12-30 02:57

    I had the same issue and JoeCortopassi is only partly right: it is caused by private browsing being enabled. The code provided in that answer does not help much though. When I tested on iPad Safari(ios5) I got

    console.log(!!window.localStorage); // true
    

    As soon as I try to set a value, I get an exception:

    localStorage.setItem("test", "test") // Exception 22 is thrown
    

    So to accurately test for local storage support, it is necessary to try and set a value in local storage, for example:

    var localStorageSupported = function() {
      try {
        localStorage.setItem("test", "test");
        localStorage.removeItem("test");
        return true;
      } catch(e){
        return false;
      }
    }
    

提交回复
热议问题