Jagst3r21 Posted December 7, 2013 Share Posted December 7, 2013 (edited) 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 Any advice is appreciated. Edited December 7, 2013 by Jagst3r21 Link to comment Share on other sites More sharing options...
davej Posted December 7, 2013 Share Posted December 7, 2013 Uh... local storage is available in HTML5... but for what you want to do a plain old-fashioned cookie would probably be fine. See... http://www.w3schools.com/js/js_cookies.asp Link to comment Share on other sites More sharing options...
Jagst3r21 Posted December 7, 2013 Author Share Posted December 7, 2013 My code not close for storage? I was advised to use localStorage over cookies by someone on JavaScript IRC chat. Link to comment Share on other sites More sharing options...
Hadien Posted December 8, 2013 Share Posted December 8, 2013 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now