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.

Where?
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.

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

Security Zone
Document limit (KB)
Domain limit (KB)

Local Machine
128
1024

Intranet
512
10240

Trusted Sites
128
1024

Internet
128
1024

Restricted
64
640

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/>
<Style>
. Storeuserdata {behavior: URL (# default # userdata );}
</Style>

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:

Attribute
Description

Expires
Set or read file expiration time

Xmldocument
Read the xml dom of a file

Method
Description

Getattribute
Reads the value of a specified attribute.

Load
Open a file

Removeattribute
Deletes a specified property.

Save
Save files

Setattribute
Assign a value to a specified attribute

The userdata file is actually an XML file that stores strings by File Name> attribute, as shown in the following sectionCode:

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 code The Code is as follows:/** @ class defines the operation of userdata */
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.
};

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: info-contact@alibabacloud.com 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.