markdown JS.WebStorage.LocalStorage.SessionStorage

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown JS.WebStorage.LocalStorage.SessionStorage相关的知识,希望对你有一定的参考价值。

///////////////////////////////////////
//The Web storage API (see the related W3C specification) introduces "two related mechanisms, similar to HTTP session cookies, for storing structured data on the client side".

// Full Documentation : https://www.w3.org/TR/webstorage/

//Indeed, Web Storage provides two interfaces - sessionStorage and localStorage //- whose main difference is data longevity. This specification defines an API //for persistent data storage of key-value pair data in Web clients.

//With localStorage the data will remain until it is deleted, whereas with //sessionStorage the data is erased when the tab/browser is closed.

//For convenience, we will mainly illustrate the localStorage object. Just //change "local" to "session" and it should work (this time with a session //lifetime).key value pairs

//Simple key-value stores, one per domain (following the same origin policy)!
//localStorage is a simple key-value store, in which the keys and values are //strings. There is only one store per domain. This functionality is exposed //through the globally available localStorage object. The same applies to //sessionStorage.

//You can view LocalStorage/SessionStorage by:
//    WebDevTools -> Application -> LocalStorage
//    WebDevTools -> Application -> Session Storage
//    ie for codepen we ll have:
//          http://codepen.io (standalone mode)
//          https://s.codepen.io (edit mode)




localStorage.lastName = "Bunny";
localStorage.firstName = "Bob"

console.log(localStorage);

var first = localStorage.firstName;
var last = localStorage.lastName;
console.log(first, last)
JS.WebStorage.LocalStorage.SessionStorage
-----------------------------------------


A [Pen](https://codepen.io/Onlyforbopi/pen/bmGvYP) by [Pan Doul](https://codepen.io/Onlyforbopi) on [CodePen](https://codepen.io).

[License](https://codepen.io/Onlyforbopi/pen/bmGvYP/license).

以上是关于markdown JS.WebStorage.LocalStorage.SessionStorage的主要内容,如果未能解决你的问题,请参考以下文章

转换rst到markdown总结

markdown [Markdown HowTo]作为Markdown语法的秘籍

python markdown干啥用的

markdown前端渲染

如何用markdown生成目录

markdown排版示例