我们的一个小应用,使用百度地图API获取到用户的坐标之后用localStorage做了下缓存,测试上线之后有运营同学反馈页面数据拉取不到,

测试的时候没有发现问题,而且2台相同的iphone一台可以一台不行,最后定位到是localStorage有问题。

但是为啥明明版本一样的2台手机一台可以一台不行呢?

而且2台手机打印localStorage明明都是Object,奇怪了。

在度娘上没找到答案,最后到google发现有人说是Private Browsing Mode引起的。然后查看IOS的safari没有发现隐私设置什么的

后来点击右下角小框框发现有个无痕浏览的模式。MD,关闭后一切正常

// Safari, in Private Browsing Mode, looks like it supports localStorage but all calls to setItem
// throw QuotaExceededError. We're going to detect this and just silently drop any calls to setItem
// to avoid the entire page breaking, without having to do 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 this is using "Private Browsing Mode". Some settings may not save or some features may not work properly for you.');
}
}

可以酱紫判断。提示用户关闭无痕模式。

IOS下的safari下localStorage不起作用的问题的更多相关文章

  1. IOS下的safari不支持localStorage?

    同事在统计日志的时候,想用localStorag去记载一些什么,但是在各大浏览器都运行的良好的基础上,唯独IOS下的safari一直静静无声,没有任何反应.打印localStorage都是Object ...

  2. Safari 下用 "location.href = filePath" 实现下载功能的诡异 bug

    Safari 下的一些诡异 bug 我们已经领教一二,比如前文中说的 无痕浏览模式下使用 localStorage 的 API 就会报错.今天我们要讲的是利用 location.href = file ...

  3. 李洪强iOS经典面试题下

    李洪强iOS经典面试题下 21. 下面的代码输出什么? @implementation Son : Father - (id)init { self = [super init]; if (self) ...

  4. iOS 点击cell下拉

    iOS  点击cell下拉 代码如下: #import "ViewController.h" @interface ViewController ()<UITableView ...

  5. ios学习--iphone 实现下拉菜单

    原文地址:ios学习--iphone 实现下拉菜单作者:sdglyuan00 #import @interface DropDown1 : UIView <</span>UITabl ...

  6. iOS 在 ARC 环境下 dealloc 的使用、理解误区

    iOS 在 ARC 环境下 dealloc 的使用.理解误区 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致&qu ...

  7. iOS - UIButton设置文字标题下划线以及下划线颜色

    创建button设置可以折行显示 - (void)viewDidLoad { [super viewDidLoad]; UIButton * button = [[UIButton alloc] in ...

  8. 【iOS】使用safari对webview进行调试

    [iOS]使用safari对webview进行调试 在web开发的过程中,抓包.调试页面样式.查看请求头是很常用的技巧.其实在iOS开发中,这些技巧也能用(无论是模拟器还是真机),不过我们需要用到ma ...

  9. 总结下Mac环境下按照appium

    第10天休息 先来总结下Mac环境下按照appium 一.相关网站 官网: http://appium.io/ 测试论坛 https://testerhome.com/wiki 二.环境准备   从官 ...

随机推荐

  1. 201604-1 折点计数 Java

    思路: 这个题要小心考虑不全.左右两边都比这个数小 或者 左右两边都比这个数大 import java.util.Scanner; public class Main { public static ...

  2. springCloud eureka服务治理集群增加安全认证

    做为SpringCloud Netflix服务套件中的一部分,springCloud eureka基于Netflix Eureka做了二次封装,默认提供WEB管理页面及服务治理. 为了确保在生产环境中 ...

  3. ant design for vue 关于table的一些问题

    1.为table添加分页: :pagination="pagination" pagination: { defaultPageSize: 10, showTotal: (tota ...

  4. Java自学-泛型 通配符

    Java 泛型通配符 ? extends super 的用法 示例 1 : ? extends ArrayList heroList<? extends Hero> 表示这是一个Hero泛 ...

  5. LeetCode——71.简化路径

    以 Unix 风格给出一个文件的绝对路径,你需要简化它.或者换句话说,将其转换为规范路径. 在 Unix 风格的文件系统中,一个点(.)表示当前目录本身:此外,两个点 (..) 表示将目录切换到上一级 ...

  6. 理解python的可变参数

    以 str.format(*args,**kwargs) 为例. "type1:{},{},{},{}_type2:{a},{b},{c},{d}".format('a',2,*[ ...

  7. systemd[1]: mariadb.service: Can't open PID file /data/mariadb/mysql/30-mariadb-1.pid (yet?) after start: No such file or directory

    环境:Centos8 编译安装Mariadb-10.4.11,安装到make install都没有问题,添加服务启动脚本到/lib/systemd/system/,服务启动脚本名为mariadb.se ...

  8. C语言中未定义的引用错误

    1.错误描述: /tmp/ccAu32Cb.o:在函数‘main’中:static.c:(.text+0x2d):对‘print_value’未定义的引用 2.通过对错误内容分析,我在编写程序时,ma ...

  9. JSONObject和JSONArray的基本使用

    一.JSONObject和JSONArray的数据表示形式 JSONObject的数据是用 {  } 来表示的, 例如:   { "name" : "佩奇", ...

  10. GIS开源库OpenSceneGraph(OSG)、OSGEarth、GDAL、Qt、CGAL、Boost

    GIS开源有这些库:OpenSceneGraph(OSG).OSGEarth.GDAL.Qt.CGAL.Boost