The Pit of iOS

Source: Internet
Author: User

One of our small applications, using Localstorage to do the next cache, test on-line after the feedback page data is not pulled,

Finally, the localstorage is a problem.

is the private browsing mode caused. Then view iOS safari without discovering privacy settings or something

Then click on the lower right corner of the small box to find a non-mark browsing mode. MD, everything's fine after it's closed.

Copy Code
//Safari, in Private browsing Mode, looks like it supports localstorage but all calls to SetItem
//Throw Q Uotaexceedederror. We ' re going to detect this and just silently drop all calls to SetItem
//To avoid the entire page breaking, without ha Ving Tsun to does a check at each usage of Storage.
if (typeof localstorage = = = ' object ') {
try {
Localstorage.setitem (' Localstorage ', 1);
Localstorage.removeitem (' localstorage ');
} catch (e) {
Storage.prototype._setitem = Storage.prototype.setItem;
Storage.prototype.setItem = function () {};
Alert (' Your Web browser does not support storing settings locally. In Safari, the most common cause of that is using "Private browsing Mode". Some settings may not be save or Some features may isn't work properly for you. ');
}
}
Copy Code
. Prompts the user to turn off the non-marking mode.

***************************************************
try {
Localstorage.setitem (key, D);
} catch (e) {
Alert ("You are in a no-trace view and cannot be saved for you");
}

The Pit of iOS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.