Use IE UserData behavior to store user data at client like cookie.
In general, we desgined a webform application need to transfer various variables between one page to another page with session or application that provided by .net frame. Session stores its data on the server so that consumed a lot of memories, if there has a method can store user data in client side which can balance server loading .
Here I want to describe a method to perform the purpose above.
Cookie also can store user data in client side,but cookie has many faults, for instance, cookie can only store max 1kb user data, cookie stores data like an array..
If we want to store more than 1kb data and the data format as xml, cookie has inablity to do the purpose. UserData behavior can store max 64kb a page, 640kb a domain. User data behavior is a portion of DHTML, supported by IE5 or later. she can store user data in xml format to your location:C:\Documents and Settings\your login name\userdata, no need to specify extra permissions, IE can calculate which place will store your data by itself, you only need to specify a id, to retrieve your data by the specified id.
For instance:
<HTML>
<HEAD>
<STYLE>
.userData {behavior:url(#default#userdata);}
</STYLE>
<SCRIPT>
function fnSaveInput(){
var oPersist=oPersistForm.oPersistInput;
oPersist.setAttribute("sPersist",oPersist.value); //将oPersist.value存储为sPersist属性
oPersist.save("oXMLBranch"); //存储在名为oXMLBranch的UserData存储区
}
function fnLoadInput(){
var oPersist=oPersistForm.oPersistInput;
oPersist.load("oXMLBranch"); //载入在名为oXMLBranch的UserData存储区
oPersist.value=oPersist.getAttribute("sPersist"); //将sPersist属性赋值给oPersist.value
}
</SCRIPT>
</HEAD>
<BODY>
<FORM ID="oPersistForm">
<INPUT CLASS="userData" TYPE="text" ID="oPersistInput">
<INPUT TYPE="button" VALUE="Load" onclick="fnLoadInput()">
<INPUT TYPE="button" VALUE="Save" onclick="fnSaveInput()">
</FORM>
</BODY>
</HTML>
Here I want to describe a method to perform the purpose above.
Cookie also can store user data in client side,but cookie has many faults, for instance, cookie can only store max 1kb user data, cookie stores data like an array..
If we want to store more than 1kb data and the data format as xml, cookie has inablity to do the purpose. UserData behavior can store max 64kb a page, 640kb a domain. User data behavior is a portion of DHTML, supported by IE5 or later. she can store user data in xml format to your location:C:\Documents and Settings\your login name\userdata, no need to specify extra permissions, IE can calculate which place will store your data by itself, you only need to specify a id, to retrieve your data by the specified id.
For instance:
<HTML>
<HEAD>
<STYLE>
.userData {behavior:url(#default#userdata);}
</STYLE>
<SCRIPT>
function fnSaveInput(){
var oPersist=oPersistForm.oPersistInput;
oPersist.setAttribute("sPersist",oPersist.value); //将oPersist.value存储为sPersist属性
oPersist.save("oXMLBranch"); //存储在名为oXMLBranch的UserData存储区
}
function fnLoadInput(){
var oPersist=oPersistForm.oPersistInput;
oPersist.load("oXMLBranch"); //载入在名为oXMLBranch的UserData存储区
oPersist.value=oPersist.getAttribute("sPersist"); //将sPersist属性赋值给oPersist.value
}
</SCRIPT>
</HEAD>
<BODY>
<FORM ID="oPersistForm">
<INPUT CLASS="userData" TYPE="text" ID="oPersistInput">
<INPUT TYPE="button" VALUE="Load" onclick="fnLoadInput()">
<INPUT TYPE="button" VALUE="Save" onclick="fnSaveInput()">
</FORM>
</BODY>
</HTML>

浙公网安备 33010602011771号