Application Range
UserData is Microsoft for IE specifically in the system to open up a storage space, so that only support the Windows+ie combination, the actual test in the IE5.5, XP (IE6, IE7), Vista (IE7) under the normal use.
where is it?
Under XP, it is generally located in the C:\Documents and Settings\ username \userdata, and sometimes in C:\Documents and Settings\ user names \application Data\microsoft\ Internet Explorer\UserData.
In Vista, located in C:\Users\ username \appdata\roaming\microsoft\internet explorer\userdata.
capacity
The Web page was made to complete the handbook by saying:
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
When used online, a single file size limit is 128KB, a domain name can save a total of 1024KB files, the number of files should be unlimited. The two values are 64KB and 640KB in the restricted site, so it is best to have a single file that controls 64KB below, given all the circumstances.
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 above statement is also the same function
Document.body.appendChild (o);
Plainly UserData is a behavior in the style, so it is the same as writing:
<input Type=hidden class= storeuserdata/>
<style>
. storeuserdata {Behavior:url (#default #userdata);}
</style>
UserData can be bound to most HTML tags, specifically:
A, acronym, address, section, B, Big, BLOCKQUOTE, BUTTON, CAPTION, CENTER, CITE, CODE, DD, DEL, DFN, DIR, DIV, DL, DT, EM, FO NT, FORM, HN, HR, I, IMG, input Type=button, input type=checkbox, input type=file, input type=hidden, input type=image, in Put Type=password, input type=radio, input type=reset, input type=submit, input type=text, KBD, LABEL, LI, LISTING, MAP, M Arquee, MENU, OBJECT, OL, OPTION, P, plaintext, PRE, Q, S, Samp, SELECT, SMALL, SPAN, STRIKE, Strong, SUB, SUP, TABLE, TEX Tarea, TT, U, UL, VAR, XM
The UserData object has the following properties and methods:
Property
Describe
Expires
Set or read the file expiration time
XmlDocument
Reading the XML DOM of a file
Method
Describe
GetAttribute
Read the value of the specified property
Load
Open File
RemoveAttribute
Deletes the specified property
Save
Save File
SetAttribute
Assign a value to a specified property
The UserData file is actually an XML file that holds the string in the form of a file name-> property, such as the following code:
O.setattribute ("code", "Hello world!");
O.save ("Baidu");
After execution, a baidu[1].xml file is generated in the UserData folder, which reads:
<rootstub code= "hello,world!" />
You can have multiple properties in a file, which means you can store many different kinds of data.
In the Music Box Link Save Project, a UserData class is encapsulated, which makes it easier to use the UserData code as follows:
Copy Code code as follows:
/** @class Define the operation of UserData * *
var UserData = {
Defining UserData Objects
O:null,
Set file Expiration time
defexps:365,
Initializing 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 file to UserData folder F-filename, C-file content, E-Expiration time
Save:function (f, C, E) {
if (Userdata.init ()) {
var o = userdata.o;
Keep the object consistent
O.load (f);
Store incoming content as a property
if (c) o.setattribute ("code", c);
Set file Expiration time
var d = new Date (), E = (arguments.length = 3)? E:userdata.defexps;
D.setdate (D.getdate () +e);
O.expires = D.toutcstring ();
Stored as a developed file name
O.save (f);
}
},
Reads the specified file from the Uerdata folder and returns it as a string. F-File name
Load:function (f) {
if (Userdata.init ()) {
var o = userdata.o;
Reading files
O.load (f);
Return file contents
Return O.getattribute ("code");
}
},
Check if the UserData file has an 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);
}
UserData function Definition End
};