Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is HTML5's Web storage?

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "what is the Web storage of HTML5". In the operation of actual cases, many people will encounter such a dilemma. Next, let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

The Web storage of HTML5 involves two parts: one is data storage, which supports more local storage schemes; the other is file reading, which supports File API.

There are two ways to store data in Web applications: one is Web server, the other is client storage, that is, local storage.

Before the advent of HTML5, there was only one way to store locally: cookie. However, cookie has obvious disadvantages, such as a small amount of data storage, which will be carried to HTTP requests to increase transmission overhead. HTML5 provides two new local storage methods: localStorage and sessionStorage.

Next, we will further explain two kinds of storage knowledge.

(1) cookie,localStorage and sessionStorage (2)

LocalStorage and sessionStorage provide the same methods, and storage-related methods are. Here is a simple example of adding, deleting, changing and searching:

At the same time, event response storage changes are supported. Once the data changes, such as increase, decrease, or modification, the event will be triggered. Examples are as follows:

Open two identical pages, click the Add button on one page, add a new piece of data to localStorage, and then look at the console of the other page, and you will find that the information is printed out. This means that the event is triggered.

HTML5 also provides File API to extract files from the hard drive and give them to the JavaScript running on the web page.

HTML5 File API can only read files and cannot modify or create files. There are four forms of reading files: (you can convert binary picture content to base64 format), the first of which is the most commonly used. Refer to the following example (displaying the contents of the selected file as a string on the page):

HTML5 also supports reading more than one file at a time, using attributes.

This is the end of the content of "what is the Web Storage of HTML5". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report