The project was previously used Localstorage, but the browser exists IE8 the following incompatibility issues, so to introduce the following userdata in IE.
There are many local storage solutions, such as Flash sharedobject, Google Gears, cookies, DOM Storage, User Data, Window.name, Silverlight, Open database, etc.
Take a picture of the web to see the current mainstream local storage scenarios:
- Cookies : widely used in the web, but the limitations are very obvious, the capacity is too small, some sites will be disabled for security reasons Cookie,cookie is not as safe as imagined, the content of the Cookie will be sent to the server along with the page request.
- Flash Sharedobject : use Kissy's store module to invoke Flash Sharedobject. The advantage of Flash Sharedobject is that the capacity is moderate, there is basically no compatibility problem, the disadvantage is to introduce a specific SWF and JS files in the page, add additional burden, processing cumbersome, or some of the machine does not have a flash operating environment.
- Google Gears : Google's offline program has stopped updating, and the official recommendation is to use HTML5 's localstorage solution.
- User Data: Microsoft for IE specifically in the system to open up a piece of storage space, so that only support windows+ie combination, the actual test in the IE5.5, XP (IE6, IE7), Vista (IE7) can be normal use. Under XP, generally located in the C:\Documents and Settings\ user name \userdata, sometimes in C:\Documents and Settings\ user name \application Data\microsoft\ Internet Explorer\UserData. Under Vista, the C:\Users\ user name is \appdata\roaming\microsoft\internet explorer\userdata; the size limit for a single file is 128KB, A total of 1024KB files can be saved under a domain name, the number of files should be unlimited. These values are 64KB and 640KB, respectively, in the restricted site, so a single file is best able to control 64KB or less if a variety of situations are considered.
- localstorage: compared with the above-mentioned local storage scheme, Localstorage has its own advantages: large capacity, easy to use, strong, native support; The disadvantage is that compatibility is poor (Chrome, Safari, Firefox,ie 9,IE8 all support Localstorage, mainly IE8 the following versions are not supported), the security is also worse (so do not use Localstorage to save sensitive information).
Mainly talk about Luserdata:
UserData
- Basic syntax:
XML: <prefix:customtag id=sid style= "Behavior:url (' #default #userdata ')"/>
HTML: <element style= "Behavior:url (' #default #userdata ')" id=sid>
- Script:
object.style.behavior = "url (' #default #userdata ')"
Object.addbehavior ("#default #userdata")
- Property:
Expires sets or gets the expiration date of the UserData behavior save data.
XMLDocument gets the XML reference.
- Method:
GetAttribute () Gets the specified property value.
Load (object) Loads the stored object data from the UserData store.
RemoveAttribute () Removes the specified property from the object.
Save object data is stored in an UserData store.
SetAttribute () Sets the specified property value.
To use the UserData storage function, you must first create an HTML tag, and then add the Behavior:url (' #default #userdata ') style attribute to the userData is stored in the HTML tag, of course, not all tags are possible , limited to some labels. To learn more, you can visit MSDN's UserData Behavior.
Examples of usage:
. Storeuserdata {behavior:url (#default#userData); } </style> <script type= "Text/javascript" >functionFnsaveinput () {varopersist=Opersistform.opersistinput; Opersist.setattribute ("Spersist", Opersist.value); Opersist.save ("Oxmlbranch"); } functionFnloadinput () {varopersist=Opersistform.opersistinput; Opersist.load ("Oxmlbranch"); Opersist.value=opersist.getattribute ("Spersist"); } </script> The UserData in IE