Cross-browser local storage Ⅰ

Cross-browser local storage Ⅰ

Original text: http://www.planabc.net/2008/08/05/userdata_behavior/
The most popular local storage nowadays is the application of cookies, but browsers have many restrictions on cookies. The biggest restriction is the total size of cookies, which is only about 4K (including name, value and equal sign).
For more complex applications and requirements, the 4K size is still a bit insignificant. In fact, many browsers (IE, Firefox, Safari) also provide their own local storage functions, which may meet our needs in specific environments.
1. userData behavior
Browser support: IE5.0 or above Basic syntax: XML:
<Prefix: CustomTag id=sID style=”behavior:url('#default#userData')” /> HTML:
<ELEMENT style=”behavior:url('#default#userData')” id=sID>
object.style.behavior = "url('#default#userData')" Script:
object.addBehavior("#default#userData")
Attribute: expires - Sets or gets the expiration date of the data saved by the userData behavior. XMLDocument -- Get a reference to the XML.
Method: getAttribute() - Gets the specified attribute value. load(object) – loads the stored object data from the userData storage area. removeAttribute() – Removes the specified attribute from an object. save(object) – stores the object data into a userData store. setAttribute() – Sets the specified attribute value.
Remark:
    For security reasons, a userData storage area can only be used to store data in the same directory and for the same protocol. Using userData behavior incorrectly may harm your application. Data in the userData storage area is not encrypted and therefore not secure. Any application that can access the UserData disk can access the data, so it is recommended not to save sensitive data, such as credit card numbers. For details: "Security Considerations: DHTML and Default Behaviors" userData behavior stores information in the storage area across sessions, which provides a dynamic data structure and larger capacity than cookies (generally 4KB). The capacity of the userData storage area depends on the security domain of the domain. The following table shows the maximum userData storage capacity, for both individual documents and for all documents in the entire domain, but based on security domains.
    Security Zone Document Limit (KB) Domain Limit (KB)
    Local achine 128 1024 Intranet 512 10240 Trusted Sites 128 1024 Internet 128 1024 Restricted 64 640 If you set the userData behavior to the html, head, title, or style objects, an error will occur when the save and load methods are called. If you must set it in style, you can set it inline or in the document header, for example:
    <style>
    .storeuserData {behavior:url(#default#userData);}
    </style>
    The ID is optional for the userData behavior, but will improve performance if included. userData can save data in XML format on the client computer, usually in the C (WIN system disk):\Documents and Settings\XXX\UserData\ folder. The userData data always exists unless it is manually deleted or the expiration date (expires) of the data is set by a script.

Mostly translated from: 《userData Behavior》

<<:  Docker image loading principle

>>:  Do you know what are the ways to jump routes in Vue?

Recommend

How to install and use Server-U 14 version

Introducing Server-U software Server-U is a very ...

Idea deploys remote Docker and configures the file

1. Modify the Linux server docker configuration f...

10 Tips to Improve Website Usability

Whether it is a corporate website, a personal blo...

Three common methods for HTML pages to automatically jump after 3 seconds

In practice, we often encounter a problem: how to...

Use of LRU algorithm in Vue built-in component keep-alive

Table of contents The use of Vue's keep-alive...

MySQL Database Iron Laws (Summary)

Good database specifications help reduce the comp...

How to build an ELK log system based on Docker

Background requirements: As the business grows la...

Several ways to implement 0ms delay timer in js

Table of contents queueMicrotask async/await Mess...

Sample code for implementing 3D book effect with CSS

Without further ado, let's take a look at the...

How to use iostat to view Linux hard disk IO performance

TOP Observation: The percentage of CPU time occup...

Summary of MySQL slow log practice

Slow log query function The main function of slow...

A brief discussion on the role of HTML empty links

Empty link: That is, there is no link with a targ...

How to change the domestic image source for Docker

Configure the accelerator for the Docker daemon S...

JS implements random roll call system

Use JS to implement a random roll call system for...