enters the code:Close the window and the console enters the code again:6. Differences between Web Storage and cookiesThe concept of Web Storage (Localstorage and Sessionstorage) is similar to a cookie, except that it is designed for larger capacity storage. The size of the cookie is limited, and every time you request a new page, the cookie is sent past, which v
solution launched by Microsoft in the browser World War in the S. It stores local data with the behaviour attribute of DHTML, allowing each page to store up to 64 K data, and each site can store up to k Data, the disadvantage of userData is obvious. It is not part of the Web standard, unless your program only needs to support IE, it is basically useless.3. Flash cookie. Flash cookies are not the same as HTTP cookies. They may be called "Flash
and 5 MB for Chrome), and the stored data will not be sent to the server again to avoid bandwidth waste.
3.1 localStorage attributes
The following table lists the attributes and methods of localStorge.
5. Differences between sessionStorage and localStorage
SessionStorage is used to locally store data in a session. The data can be accessed only on pages in the same session. When the session ends, the data is also destroyed. SessionStorage is not a persistent
browser closes. Store by domain name, does not conflict with other domain name key-value pairs storage: key/valueLocalstorage API1.setItem (key, value), save or set data. If key already exists, overwrite the value corresponding to key and add key and value if it does not exist.2.key (index); Gets the key that specifies the location of the subscript3.length Get localstorage How many data are there altogether?The method of traversing Localstorage data
Store. js is a LocalStorage package compatible with all browsers and does not require cookies or Flash. Store. js enables local storage. store. js-LocalStorage)
Store. js is a LocalStorage package compatible with all browsers and does not require cookies or Flash. Store. js automatically uses localStorage, globalStorage, or userData Based on the browser to implement
1, storage data 20M2. Properties under Window.localstorage Object3. Data can only store strings4. Localstorage must be deleted manuallyHow to use Localstorage:Const A = Window.localstorage;Store data: A.setitem (' Name of data ', ' data ');Cancellation Data: A.getitem (' Name of the data ');Delete data: A.removeitem (' Name of data ');Erase data: A.clear ();To store data:Json.stringify () Converts an object into a string;Json.parse () Converts a strin
a function.Similar to the sorted function in Python. For example dic={' name ': ' Xuequn ', ' age ': +, ' sex ': 1} sorted (Dic.items (), Key=lambda x:x[1]) #以字典的键排序JavaScript is the same. The default sort () function sorts the letters of an element, which is the ASCII code. But we can also define our own functions. For example:9, Splice () Add/remove items from the array, and then return the deleted ite
session, the window once closed. The usage is exactly the same.
Previously, these were all done by cookies. However, cookies are not suitable for storing large amounts of data because they are passed by each request to the server, which makes the cookie slow and inefficient.
In HTML5, the data is not passed by each server request, but only when the data is used on the request. It makes it possible to store large amounts of data without compromising site performance.
For different sites, t
Very comprehensive front-end local storage explanation, storage explanationThree Local Storage Methods: cookiePreface
One of the biggest problems in the early days of the network was how to manage the status. In short, the server cannot know whether two requests come from th
APIs are widely implemented and supported, web applications can use file-based storage mechanisms.LocalStorage and sessionStorage
These two attributes represent the same Storage object, that is, a persistent associated array. arrays are indexed using strings, and stored values are also in the string format. The usage of Stor
clear () ;}; copy the code called DOMString: A UTF-16 String, JavaScript uses this encoding String, so DOMString is equivalent to a String in JavaScript. each storage object provides a list of key/value pairs, called data items. Key can be any string (including empty strings) or value can be any string. The standardized interface provides localStorage. length, a
standardization of such APIs has failed. And neither IE nor Firefox seems to be implementing this API. There is also a database API that is being standardized, called the Index database API. Calling the API returns a simple database object that does not contain a query language. Both of these client-side database APIs are asynchronous and use event-handling mechanisms.L File System APIPreviously introduced the mainstream browser now supports a file object to upload selected files to the server
Database Storage for HTML5 local Storage, html5storage
In the previous article Web Storage of HTML5 local Storage, we briefly introduced how to use localStorage to implement local
client browser, but also support the complex local database, so that JS more efficient. HTML5 supports two types of webstorage:Persistent local Storage (localstorage)Session-level local storage (sessionstorage)Ii. Classification of loca
previous article. The functions to be implemented are as follows:
You can create a contact and save it to the database. The contact fields include name, mobile phone number, company, and creation time;
Lists all currently saved contact information;
You can delete specific contact information;Similarly, prepare an HTML page as follows:Share the best UI front-end framework !. Code
Comments: In fact, in addition to sessionStorage and localStorage, HTML5 also supports local data storage through local databases. HTML5 adopts the "SQLLite" file-type database, which is mostly concentrated on embedded devices, if you are familiar with IOS/Android development, you should be familiar with SQLLite databases. In the previous HTML5
HTML5 local storage and HTML5 Storage
1. sessionStorage
2. localStorage
3. Database Storage
4. globalStorage
5. Compatibility
References
Local persistent storage has always been an advantage of
Storage
You can use JavaScript to access HTML5 Storage and use the localStorage object of the global window object. Before using it, we need to first check whether it is available:Function supports_html5_storage (){Try {Return 'localstore' in window window ['localstore']! = Null;} Catch (e ){Return false;}}HTML5 Storage
is to interact with the server as part of the HTTP specification, whereas Web Storage is only for local "storage" of data (corrections from @otakustay)HTML5 Web Storage Browser support situationBrowser support in addition to IE7 and the following are not supported, other standard browsers are fully supported (IE and F
First you can take a look at the JavaScript local storage practices (HTML5 localstorage and IE UserData)Sessionstorage and the localstorage mentioned above are very familiar, and the method is almost the same:Very easy to understand interface:Sessionstorage.getitem (Key): Gets the value that the specified key is stored locally sessionstorage.setitem (key,value) :
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.