QUOTA_EXCEEDED_ERR in Mobile Safari

By  on  

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:

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:

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.

Recent Features

Incredible Demos

  • By
    DWRequest: MooTools 1.2 AJAX Listener & Message Display

    Though MooTools 1.2 is in its second beta stage, its basic syntax and theory changes have been hashed out. The JavaScript library continues to improve and become more flexible. Fellow DZone Zone Leader Boyan Kostadinov wrote a very useful article detailing how you can add a...

  • By
    Printing MooTools Accordion Items

    Sometimes we're presented with unforeseen problems when it comes to our JavaScript effects. In this case, I'm talking about printing jQuery and MooTools accordions. Each "closed" accordion content element has its height set to 0 which means it will be hidden when the...

Discussion

  1. Your site hit the nail on the head. I discovered the best VPN for Gaming at this site http://www.anonymousvpnsoftware.com

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!