最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What is window.localStorage - Stack Overflow

programmeradmin3浏览0评论

The option.js file of "Email this page" (Chrome extension example) contains the following code:

if (window.localStorage == null) {
  ...
if (window.localStorage.customMailtoUrl == null) {

What does this mean? What is window.localStorage?

The option.js file of "Email this page" (Chrome extension example) contains the following code:

if (window.localStorage == null) {
  ...
if (window.localStorage.customMailtoUrl == null) {

What does this mean? What is window.localStorage?

Share Improve this question edited Apr 8, 2012 at 10:33 Rob W 349k87 gold badges807 silver badges682 bronze badges asked Apr 8, 2012 at 1:36 Siddhpura AmitSiddhpura Amit 15.1k17 gold badges95 silver badges154 bronze badges 6
  • 1 appdeveloper.intel.com/en-us/article/… – Kirk Woll Commented Apr 8, 2012 at 1:42
  • 1 @AndyRay "let me google it for you", i suspect. – c69 Commented Apr 8, 2012 at 11:05
  • stackoverflow.com/tags/local-storage/info – c69 Commented Apr 8, 2012 at 11:06
  • @c69 I want you to think very carefully about what you just did, and then give yourself a time out. – Andy Ray Commented Apr 8, 2012 at 11:35
  • what o_O ? you asked - i answered: "what is lmgtfy? – @AndyRay 1 hour ago" – c69 Commented Apr 8, 2012 at 12:05
 |  Show 1 more comment

3 Answers 3

Reset to default 14

localStorage/sessionStorage is part of HTML5 API. Essentially, this is what cookies are used for. But this is a lot better.

https://developer.mozilla.org/en/DOM/Storage

From http://www.w3schools.com/html/html5_webstorage.asp:

"What is HTML Local Storage?

With local storage, web applications can store data locally within the user's browser.

Before HTML5, application data had to be stored in cookies, included in every server request. Local storage is more secure, and large amounts of data can be stored locally, without affecting website performance.

Unlike cookies, the storage limit is far larger (at least 5MB) and information is never transferred to the server.

Local storage is per domain. All pages, from one domain, can store and access the same data."

localStorage is a property of HTML5 API which allows web applications to store data locally within the user's browser.

Before HTML5, application data had to be stored in cookies, included in every server request. localStorage is a different property which has many advantages over cookies.

HTML local storage provides two objects for storing data on the client:

window.localStorage - stores data with no expiration date

window.sessionStorage - stores data for one session (data is lost when the browser tab is closed)

localStorage features:

  • The localStorage data has no expiration date.
  • localStorage is more secure since it doesn't send anything to server, everything happens at client side i.e. browser.
  • localStorage is per origin means two or more html pages, from one origin, can store and access the same data stored in localStorage Object.
  • It can store much more data than cookies. The storage size varies for each browser for example the latest versions of chrome & firefox can store atleast 5MB of data.
发布评论

评论列表(0)

  1. 暂无评论