cfs_quota_Mobile Safari中的QUOTA_EXCEEDED_ERR

cfs_quota

I've been working on an HTML5 application for the new Mozilla Marketplace, writing a tutorial along the way to help all of you create and promote your HTML5 web-powered app.  The HTML5 app uses localStorage to save basic search history, as well as other newer APIs.  While testing my application on my iPhone, I was seeing the following error:

我一直在为新的Mozilla Marketplace开发 HTML5应用程序,并在编写教程的过程中帮助所有人创建和推广HTML5网络驱动的应用程序。 HTML5应用程序使用localStorage来保存基本搜索历史记录以及其他较新的API。 在iPhone上测试应用程序时,出现以下错误:


localStorage.setItem("history", JSON.stringify(myObject));


The error caused my app to break, refreshing the page and rendering the app useless!  After a bit of research, I found that the reason for the error was that my Mobile Safari's Private Browsing was turned on.  You'd expect a silent error when this mode is one, but nope -- simply a bricked app.  Since there's no way to detect if the user's browser is in "Private Browsing" is turned on (feature detection still works), the best solution is to wrap localStorage setters in try {} / catch() {} blocks:

该错误导致我的应用程序损坏,刷新页面并使该应用程序无用! 经过一番研究,我发现该错误的原因是我的Mobile Safari的“私人浏览”已打开。 当这种模式是一种模式时,您会期待一个无声的错误,但不是-仅仅是一个砖砌的应用程序。 由于无法检测用户的浏览器是否处于“私人浏览”状态(功能检测仍然有效),因此最好的解决方案是将localStorage设置器包装在try {} / catch() {}块中:


try {
	localStorage.setItem("history", JSON.stringify(myObject));
}
catch(e) {}


I'm not seeing a better solution at the moment.  Since there's now way to track Private Mode, and certain interactions break in this mode, using try {} / catch() {} blocks appears to be the best solution.

我目前没有更好的解决方案。 由于现在有了跟踪专用模式的方法,并且某些交互在此模式下中断,因此使用try {} / catch() {}块似乎是最好的解决方案。

翻译自: https://davidwalsh.name/quota_exceeded_err

cfs_quota

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值