Skip to content
Advertisement

Tag: local-storage

Check if localStorage is available

I know there has been many questions about checking for localStorage but what if someone manually shuts it off in their browser? Here’s the code I’m using to check: Simple function and it works. But if I go into my Chrome settings and choose the option “Don’t Save Data” (I don’t remember exactly what it’s called), when I try to

Push JSON Objects to array in localStorage

I have a function in Javascript: the data parameter is a JSON Object. But everytime I click the button it overwrites the data in my localstorage. Does anybody know how to do this? Answer There are a few steps you need to take to properly store this information in your localStorage. Before we get down to the code however, please

localStorage – use getItem/setItem functions or access object directly?

Are there some benefits of using the methods defined on the localStorage object versus accessing the object properties directly? For example, instead of: I have been doing this: Is there anything wrong with this? Answer Not really, they are, basically, exactly the same. One uses encapsulation (getter/setter) to better protect the data and for simple usage. You’re supposed to use

Does HTML5 localStorage maximum size include key names?

HTML5’s localStorage WebStorage has a maximum size of 5MB. Does this include the key names? For instance, if I were to use key names “quite-a-long-key-name-and-this-is-only-1” instead of “key1”, would I run out of space sooner? On a slightly related topic; is there any de-facto convention for naming localStorage keys? How are namespace collisions prevented when using third party JS scripts?

Is there a way to increase the size of localStorage in Google Chrome to avoid QUOTA_EXCEEDED_ERR: DOM Exception 22

I’ve written a webapp that allows you to store the images in the localStorage until you hit save (so it works offline, if signal is poor). When the localStorage reaches 5MB Google Chrome produces an error in the javascript console log: Uncaught Error: QUOTA_EXCEEDED_ERR: DOM Exception 22 How do I increase the size of the localStorage quota on Google Chrome?

How to store objects in HTML5 localStorage/sessionStorage

I’d like to store a JavaScript object in HTML5 localStorage, but my object is apparently being converted to a string. I can store and retrieve primitive JavaScript types and arrays using localStorage, but objects don’t seem to work. Should they? Here’s my code: The console output is It looks to me like the setItem method is converting the input to

Advertisement