UserData usage summary produced by lanyu_javascript skills
WBOYOriginal
2016-05-16 18:24:051107browse
Application Scope UserData is a storage space specially opened by Microsoft in the system for IE, so it only supports the combination of Windows IE. The actual test was in 2000 (IE5.5), XP (IE6, IE7 ), it can be used normally under Vista (IE7). Where is
? Under XP, it is usually located in C:Documents and Settings username UserData. Sometimes it is located in C:Documents and SettingsusernameApplication DataMicrosoftInternet ExplorerUserData.
Under Vista, located in C:UsersusernameAppDataRoamingMicrosoftInternet ExplorerUserData.
Capacity The web page production manual says 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
When used online, the size limit of a single file is 128KB, under one domain name A total of 1024KB files can be saved, and there should be no limit to the number of files. In restricted sites, these two values are 64KB and 640KB respectively, so if various circumstances are taken into account, it is best to control a single file to be less than 64KB.
How to use? 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 has the same effect document.body.appendChild(o);
To put it bluntly, UserData is a Behavior in the style, so it is the same when written like this:
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
UserData object has the following attributes and methods:
Attribute Description
expires Set or read the file expiration time
XMLDocument Read the XML DOM of the file
Method Description
getAttribute Read the value of the specified attribute
load Open the file
removeAttribute Remove the specified attribute
save Save the file
setAttribute Assign a value to the specified attribute
The UserData file is actually an XML file, and the string is saved through the file name->attribute, such as the following code:
/**@class defines the operation of userdata*/ var UserData = { // Define userdata object o : null, // Set file expiration time defExps: 365, //Initialize 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, e-expiration time save : function(f, c, e){ if( UserData.init()){ var o = UserData.o; // Keep the object consistent o.load(f); // Store the 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(); // Save as 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 file o.load (f); // Return file content return o.getAttribute("code"); } }, // Check whether the userdata file exists 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); } //End of UserData function definition };
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn