admin管理员组文章数量:1336092
I want to replicate Local Storage concept (similar to HTML5) in javascript or jquery.
But unfortunately I don't have idea, how to start this.
Can any one suggest how to implement local storage using javascript or jquery (Without using HTML5)?
I want to replicate Local Storage concept (similar to HTML5) in javascript or jquery.
But unfortunately I don't have idea, how to start this.
Can any one suggest how to implement local storage using javascript or jquery (Without using HTML5)?
Share Improve this question asked Jan 2, 2012 at 5:38 Siva CharanSiva Charan 18.1k10 gold badges63 silver badges95 bronze badges 7- Why the restriction on HTML5? – Sergio Tulentsev Commented Jan 2, 2012 at 5:39
- You could use a flash proxy (use its local storage instead of HTML5's one) – Sergio Tulentsev Commented Jan 2, 2012 at 5:40
- You can't. JS can't access the filesystem, so where would your data be stored? Unless you want to use a cookie? – nnnnnn Commented Jan 2, 2012 at 5:40
- I have a restriction not use cookies and business wants to store the data on the browser location itself that is similar to HTML5. I can't use HTML5 for only this, since I need to support most of all browsers including old versions too. please suggest how best I can achieve this. – Siva Charan Commented Jan 2, 2012 at 5:45
- You'll have to tell whomever is setting the business requirements that it can't be done. – nnnnnn Commented Jan 2, 2012 at 5:58
3 Answers
Reset to default 5This is a bit of a fools errand because all modern browsers support localStorage and sessionStorage at this point. Its as simple as doing this:
sessionStorage.somesessionstorage = 'some session string value';
localStorage.somelocalstorage = 'some local storage value';
If you use this in conjunction with stringify to serialize and deserialize objects like so:
// serialize
sessionStorage.somesessionstorage = JSON.stringify(myObj);
// deserialize
var obj = JSON.parse(sessionStorage.somesessionstorage);
You can use cookies if you want to go against the grain and be silly. Otherwise, start to incorporate HTML5 features.
Keep in mind HTML5 is a big word and should not be in your head as describing everything. You should pick the more supported features over the less supported ones.
An incredible resource I love is the following website http://html5demos./ which very clearly lists out support in browsers. This will clear up your thinking.
Try this jQuery plugin:
http://www.jstorage.info/
Will try various methods depending on the browser's capability.
EDIT:
And another (can use Flash/Silverlight/image based "cookies"):
http://samy.pl/evercookie/
You can use this jQuery plugin : https://github./julien-maurel/jQuery-Storage-API
But you'll always need cookies on old browser to simulate storage...
本文标签: Local Storage using JavascriptJquery (Without using HTML5)Stack Overflow
版权声明:本文标题:Local Storage using JavascriptJquery (Without using HTML5) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742393005a2466363.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论