Jump to content

HTML5 localStorage


Jagst3r21

Recommended Posts

I have a message bar that I made, but am not the best with scripting, so not sure how to handle the local storage

Here is what I have so far http://jsfiddle.net/nDtWM/16/

I believe I have it rigged so it is persistent until the user clears the cache, but am not sure. Also, it does not work so I cannot know :P

Any advice is appreciated.

Edited by Jagst3r21
Link to comment
Share on other sites

no, local storage is better than cookies in every way. it can store more information than cookies can ever dream to, its far more secure as websites can't access other websites local storage, and consumes far less bandwith/overhead (local storage starts and ends on the client's browser, it never goes to the server. and it is only accessed when needed, cookies are always parsed even if you're not gonna use them).

 

your jsfiddle didn't include the jQuery library, so its not even getting to anything inside that $(document).ready.

 

you also forgot to check if local storage is supported on the browser. older browsers do not have this support and will simply error cause it doesn't know what localstorage is. you also need to enforce html5 doctype (which your jsfiddle is doing)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...