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

  • By
    LightFace:  Facebook Lightbox for MooTools

    One of the web components I've always loved has been Facebook's modal dialog.  This "lightbox" isn't like others:  no dark overlay, no obnoxious animating to size, and it doesn't try to do "too much."  With Facebook's dialog in mind, I've created LightFace:  a Facebook lightbox...

  • By
    Conquering Impostor Syndrome

    Two years ago I documented my struggles with Imposter Syndrome and the response was immense.  I received messages of support and commiseration from new web developers, veteran engineers, and even persons of all experience levels in other professions.  I've even caught myself reading the post...

Incredible Demos

  • By
    jQuery Wookmark

    The first thing that hits you when you visit Pinterest is "Whoa, the columns are the same width and the photos are cut to fit just the way they should."  Basic web users probably think nothing of it but as a developer, I can appreciate the...

  • By
    Fading Links Using jQuery:  dwFadingLinks

    UPDATE: The jQuery website was down today which caused some issues with my example. I've made everything local and now the example works. Earlier this week, I posted a MooTools script that faded links to and from a color during the mouseover and mouseout events.

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!