UserData usage Summary by lanyu

Source: Internet
Author: User

Application Scope
UserData is a storage space opened by Microsoft for IE in the system. Therefore, it only supports the combination of Windows and IE. In actual tests, UserData is used in 2000 (IE5.5), XP (IE6, IE7 ), vista (IE7) can be used normally.

In XP, it is generally located in C: \ Documents ents and Settings \ USERNAME \ UserData, sometimes in C: \ Documents ents and Settings \ USERNAME \ Application Data \ Microsoft \ Internet Explorer \ UserData.

In Vista, It is located at C: \ Users \ User Name \ AppData \ Roaming \ Microsoft \ Internet Explorer \ UserData.

In the webpage creation completion manual, we can say this:

Security Zone
Document Limit (KB)
Domain Limit (KB)

Local Machine


Trusted Sites



For online use, the size of a single file is limited to kb. a domain name can store a total of KB of files. There should be no limit on the number of files. In a restricted site, these two values are 64KB and 640KB respectively. Therefore, it is best to control a single file under 64KB if you consider various situations.

How to use it?
Use the following JS statement to create an object that supports UserData:

O = document. createElement ('input ');
O. type = "hidden ";
O. addBehavior ("# default # userData ");
// UserData. o. style. behavior = "url ('# default # userdata ')";
// The preceding statement also plays the same role
Document. body. appendChild (o );

To put it bluntly, UserData is a Behavior in the style, so the write is the same:

<Input type = hidden class = storeuserData/>
. StoreuserData {behavior: url (# default # userData );}

UserData can be bound to most html tags, specifically:

A, ACRONYM, ADDRESS, AREA, B, BIG, BLOCKQUOTE, BUTTON, CAPTION, CENTER, CITE, CODE, DD, DEL, DFN, DIR, DIV, DL, DT, EM, FONT, FORM, hn, HR, I, IMG, INPUT type = button, INPUT type = checkbox, INPUT type = file, INPUT type = hidden, INPUT type = image, INPUT type = password, INPUT type = radio, INPUT type = reset, INPUT type = submit, INPUT type = text, KBD, LABEL, LI, LISTING, MAP, MARQUEE, MENU, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, Q, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, SUB, SUP, TABLE, TEXTAREA, TT, U, UL, VAR, XM

The UserData object has the following attributes and methods:


Set or read file expiration time

Read the xml dom of a file


Reads the value of a specified attribute.

Open a file

Deletes a specified property.

Save files

Assign a value to a specified attribute

The UserData file is actually an XML file. You can use the File Name> attribute to save the string, as shown in the following code:

O. setAttribute ("code", "hello world! ");
O. save ("baidu ");

After execution, a baidu [1]. xml file is generated in the UserData folder. The content of the file is:
<ROOTSTUB code = "hello, world! "/>

A file can have multiple attributes, that is, it can store a variety of different data.

A UserData class is encapsulated in the saved project of the music box link, which makes it easier to use UserData. The Code is as follows:
Copy codeThe Code is as follows:
/** @ Class defines userdata operations */
Var UserData = {
// Define the userdata object
O: null,
// Set the file expiration time
DefExps: 365,
// Initialize the userdate object
Init: function (){
If (! UserData. o ){
Try {
UserData. o = document. createElement ('input ');
UserData. o. type = "hidden ";
// UserData. o. style. behavior = "url ('# default # userdata ')";
UserData. o. addBehavior ("# default # userData ");
Document. body. appendChild (UserData. o );
} Catch (e ){
Return false;
Return true;
// Save the file to the userdata folder f-file name, c-file content, and e-expiration time
Save: function (f, c, e ){
If (UserData. init ()){
Var o = UserData. o;
// Keep the object consistent
O. load (f );
// Store the imported content as an attribute
If (c) o. setAttribute ("code", c );
// Set the file expiration time
Var d = new Date (), e = (arguments. length = 3 )? E: UserData. defExps;
D. setDate (d. getDate () + e );
O. expires = d. toUTCString ();
// Store the specified file name
O. save (f );
// Read the specified file from the uerdata folder and return it as a string. F-file name
Load: function (f ){
If (UserData. init ()){
Var o = UserData. o;
// Read the file
O. load (f );
// Return the File Content
Return o. getAttribute ("code ");
// Check whether the userdata file contains the f-file name
Exist: function (f ){
Return UserData. load (f )! = Null;
// Delete the specified file f-file name in the userdata folder
Remove: function (f ){
UserData. save (f, false,-UserData. defExps );
// The UserData Function Definition ends.

Related Article

Contact Us

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: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.