IOS下的safari下localStorage不起作用的问题
我们的一个小应用,使用百度地图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不起作用的问题的更多相关文章
- IOS下的safari不支持localStorage?
同事在统计日志的时候,想用localStorag去记载一些什么,但是在各大浏览器都运行的良好的基础上,唯独IOS下的safari一直静静无声,没有任何反应.打印localStorage都是Object ...
- Safari 下用 "location.href = filePath" 实现下载功能的诡异 bug
Safari 下的一些诡异 bug 我们已经领教一二,比如前文中说的 无痕浏览模式下使用 localStorage 的 API 就会报错.今天我们要讲的是利用 location.href = file ...
- 李洪强iOS经典面试题下
李洪强iOS经典面试题下 21. 下面的代码输出什么? @implementation Son : Father - (id)init { self = [super init]; if (self) ...
- iOS 点击cell下拉
iOS 点击cell下拉 代码如下: #import "ViewController.h" @interface ViewController ()<UITableView ...
- ios学习--iphone 实现下拉菜单
原文地址:ios学习--iphone 实现下拉菜单作者:sdglyuan00 #import @interface DropDown1 : UIView <</span>UITabl ...
- iOS 在 ARC 环境下 dealloc 的使用、理解误区
iOS 在 ARC 环境下 dealloc 的使用.理解误区 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致&qu ...
- iOS - UIButton设置文字标题下划线以及下划线颜色
创建button设置可以折行显示 - (void)viewDidLoad { [super viewDidLoad]; UIButton * button = [[UIButton alloc] in ...
- 【iOS】使用safari对webview进行调试
[iOS]使用safari对webview进行调试 在web开发的过程中,抓包.调试页面样式.查看请求头是很常用的技巧.其实在iOS开发中,这些技巧也能用(无论是模拟器还是真机),不过我们需要用到ma ...
- 总结下Mac环境下按照appium
第10天休息 先来总结下Mac环境下按照appium 一.相关网站 官网: http://appium.io/ 测试论坛 https://testerhome.com/wiki 二.环境准备 从官 ...
随机推荐
- JNI的第2种写法:本地方法注册
声明:迁移自本人CSDN博客https://blog.csdn.net/u013365635 孔乙己说,茴香豆的茴有四种写法,今天谈谈JNI的第2种写法:本地方法注册. 这种写法的好处是不需要使用ja ...
- day57-mysql-五种约束和sql语句逻辑执行顺序
二.sql语句逻辑执行顺序 () SELECT () DISTINCT <select_list> 去重复 () FROM <left_table> () <join_t ...
- 脚手架搭建vue项目
1.安装安装node.js: 2.cnpm install vue-cli -g (全局安装,需要注意的是我这里是用淘宝镜像安装的,没有安装cnpm的需要先去安装一下) 3.vue --version ...
- Opencv笔记(九)——图像阈值
学习目标: 学习简单阈值,自适应阈值,Otsu's 二值化等 学习函数cv2.threshold,cv2.adaptiveThreshold 等. 一.简单阈值 与名字一样,这种方法非常简单.但像素值 ...
- 2019-2020-1 20199324《Linux内核原理与分析》第五周作业
第四章 系统调用的三层机制(上) 知识点总结: 系统调用:系统调用是操作系统为用户态进程与硬件设备进行交互提供的一组接口. 系统调用的功能特性: 把用户从底层的硬件编程中解放出来: 极大地提高了系统的 ...
- VS2010 保护视力 背景色设置
vs2010——工具——选项---环境——字体和颜色——纯文本——项背景色——自定义 色调:88 饱和度:92 亮度:209
- 谁能率先挖掘出5G金矿?
现在,消费者已经习惯4G的存在,它好像另外的一个太阳,点亮了夜生活,也丰富了白天的生活:随时随地的直播.视频通话.移动支付.嘀嘀打车等等,这些都因4G网络和智能手机而快速发展,帮助消费者清理碎片时间之 ...
- 让Spring不再难懂-aop篇
什么是aop AOP(Aspect-OrientedProgramming,面向方面编程),可以说是OOP(Object-Oriented Programing,面向对象编程)的补充和完善.OOP允许 ...
- King of the Waves
You are organising a king of the hill tournament, the Buenos Aires Paddleboarding Competition (BAPC) ...
- kettle的基本使用
一.下载下载kettlehttp://sourceforge.net/projects/pentaho/files/Data%20Integration/7.0/pdi-ce-7.0.0.0-25.z ...