Safari的html5 localStorage错误:“ QUOTA_EXCEEDED_ERR:DOM异常22:试图向存储中添加超出配额的内容。”
显然,这是设计使然。当Safari(OS X或iOS)处于私有浏览模式时,它似乎localStorage可用,但是尝试调用setItem会引发异常。
store.js line 73'QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to add something to storage that exceeded the quota.'
发生的事情是该窗口对象仍在localStorage全局命名空间中公开,但是当您调用时setItem,将抛出此异常。的所有呼叫都将removeItem被忽略。
我相信最简单的解决方法(尽管我尚未测试过此跨浏览器)将更改功能isLocalStorageNameSupported()以测试您是否还可以设置一些值。
function isLocalStorageNameSupported() { var testKey = ’test’, storage = window.sessionStorage; try {storage.setItem(testKey, ’1’);storage.removeItem(testKey);return localStorageName in win && win[localStorageName]; } catch (error) {return false; }}解决方法
我的webapp在ios Safari私人浏览中出现javascript错误:
JavaScript:错误
未定义
QUOTA_EXCEEDED_ERR:DOM异常22:试图向存储中添加内容…
我的代码:
localStorage.setItem(’test’,1)
相关文章:
1. android - 启动模拟器的,报“Could not automatically detect an ADB binary……”,要怎么解决?2. 如何分别在Windows下用Winform项模板+C#,在MacOSX下用Cocos Application项目模板+Objective-C实现一个制作游戏的空的黑窗口?3. python - TypeError: tryMsgcode() takes exactly 2 arguments (0 given)4. javascript - 关于json中获取多个key-value对中多层嵌套key的name5. 关于docker下的nginx压力测试6. docker安装后出现Cannot connect to the Docker daemon.7. android clickablespan获取选中内容8. javascript - 最终生成的jsBundle文件压缩问题9. angular.js - angularjs的自定义过滤器如何给文字加颜色?10. node.js - 如何在服务器部署vuejs项目?
