Localstorage support in Safari non-mark browsing mode in iOS

Source: Internet
Author: User

Before the preface, the test raised a bug, in the Apple phone in the no-trace mode, the search button is not working, unable to jump page, and search history is not displayed (user search history using Localstorage storage). Text iOS on Sarfari in the non-trace mode, the browser pretends to support Localstorage, and on the global window burst the method, so the checksum is Localstorage object, but when the call SetItem to save, the reportError:quotaexceedederror ...: The quota has been exceeded.As a result, a small test was carried out ... and may not be fully tested! 1. Test model IPhone7 plus version 11.3 iPhone6 plus version 11.3.1 iPhone6 version 10.2.1 Iphonese version 9 Oppe r92. Test browser Sarfa Ri UC comes with browser 3. Results: IOS9,IOS10 SarfariSetItem error GetItem NULL IOS SarfariSetItem can be set GetItem can get IOS to UCSetItem not set, but no error getItem null AndroCan be set, can get 4. Conclusion: Only IOS9, 10 and localstorage can not be used, IOS11 Sarfari has supported access Localstorage, but iOS11 is not supported in UC. Therefore, the use of loaclstorage in the development process needs to be compatible with the above situation, to avoid JS error after affecting the entire page function. 5. Solve the code and points of attention: 1. Use Try/catch 2. Only for SetItem, to determine whether the browser turns on no trace mode
Determine if browsing supports localstoragefunction islocalstoragesupport{    try {        var issupport = ' localstorage ' in Window & & window[' localstorage ']!== null;        if (issupport) {        Localstorage.setitem ("Local_storage_test", "1");        Localstorage.removeitem ("Local_storage_test");        }        return issupport;    } catch (e) {        return false;    }} Determines whether the browser turns on the non-marking mode function  isinprivate () {      try {        localstorage.setitem ("Local_storage_test", "1");        Localstorage.removeitem ("Local_storage_test");        return false;      } catch (e) {        return true;      }    }

  

Localstorage support in Safari non-mark browsing mode in iOS

Related Article

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.