https://msdn.microsoft.com/zh-cn/vstudio/ms531424
userData Behavior

This topic documents a feature of Binary Behaviors, which are obsolete as of Internet Explorer 10.

Enables the object to persist data in user data.

Syntax

XML <Prefix: CustomTag ID=sID STYLE=" behavior:url('#default#userData')" />
HTML <ELEMENT STYLE="behavior:url('#default#userData')" ID=sID>
Scripting objectstyle.behavior = "url('#default#userData')"
objectaddBehavior ("#default#userData")

Possible Values

Prefix Prefix that associates the CustomTag with an XML namespace. This prefix is set using the XMLNS attribute of the HTML tag.
CustomTag User-defined tag.
sID String that specifies a unique identifier for the object.
 

Members Table

The following table lists the members exposed by the userData object.

Attributes/Properties
Property Description
expires Sets or retrieves the expiration date of data persisted with the userData behavior.
XMLDocument Retrieves a reference to the XML
Methods
Method Description
getAttribute Retrieves the value of the specified attribute.
load Loads an object participating in userData persistence from a UserData store.
removeAttribute Removes the specified attribute from the object.
save Saves an object participating in userData persistence to a UserData store.
setAttribute Sets the value of the specified attribute.

Remarks

 Security Alert  For security reasons, a UserData store is available only in the same directory and with the same protocol used to persist the store.
 Security Alert  Using this behavior incorrectly can compromise the security of your application. Data in a UserData store is not encrypted and therefore not secure. Any application that has access to the drive where UserData is saved has access to the data. Therefore, it is recommended that you not persist sensitive data like credit card numbers. For more information, see Security Considerations: DHTML and Default Behaviors.

The userData behavior persists information across sessions by writing to a UserData store. This provides a data structure that is more dynamic and has a greater capacity than cookies. The capacity of the UserData store depends on the security zone of the domain. The following table shows the maximum amount of UserData storage that is available for an individual document and also the total available for an entire domain, based on the security zone.

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

See URLACTION_HTML_USERDATA_SAVE for information on how the userData behavior is regulated. See About URL Security Zones Templates for further information on the default URL policy settings for each of the five security zone templates.

The userData behavior persists data across sessions, using one UserData store for each object. The UserData store is persisted in the cache using thesave and load methods. Once the UserData store has been saved, it can be reloaded even if the document has been closed and reopened.

Setting the userData behavior class on the htmlheadtitle, or style object causes an error when the save or load method is called.

The required style can be set inline or in the document header, as follows:

   <STYLE> 
      .storeuserData {behavior:url(#default#userData);} 
   </STYLE>

An ID is optional for userData, but including one improves performance.

The userData behavior is available as of Microsoft Internet Explorer 5, in the Microsoft Win32 and Unix platforms.

Examples

This example uses the userData behavior to preserve information in a UserData Store.

<html> 
 
<head> 
<style type="text/css"> 
.storeuserData { 
    behavior: url(#default#userData); 

</style> 
<script type="text/javascript"> 
function fnSaveInput(){ 
   var oPersist=oPersistForm.oPersistInput; 
   oPersist.setAttribute("sPersist",oPersist.value); 
   oPersist.save("oXMLBranch"); 

function fnLoadInput(){ 
   var oPersist=oPersistForm.oPersistInput; 
   oPersist.load("oXMLBranch"); 
   oPersist.value=oPersist.getAttribute("sPersist"); 

</script> 
</head> 
 
<body> 
 
<form id="oPersistForm"> 
    <input class="storeuserData" type="text" id="oPersistInput"> 
    <input type="button" value="Load" onclick="fnLoadInput()"> 
    <input type="button" value="Save" onclick="fnSaveInput()"> 
</form> 
 
</body> 
 
</html>

Code examplehttp://samples.msdn.microsoft.com/workshop/samples/author/persistence/userData_1.htm

The following example uses the userData behavior in a custom tag to preserve information in a UserData Store.

<html xmlns:sdk=""> 
 
<head> 
<style type="text/css"> 
sdk\:cacher { 
    behavior: url(#default#userData); 

</style> 
<script type="text/javascript"> 
function fnSaveInput(){ 
   cachetag.setAttribute("sPersist",txt1.value); 
   cachetag.save("cache"); 

function fnLoadInput(){ 
   cachetag.load("cache"); 
   cachetag.value=cachetag.getAttribute("sPersist"); 

</script> 
</head> 
 
<body> 
 
<sdk:cacher id="cachetag"></sdk:cacher> 
<input type="button" value="Load" onclick="fnLoadInput()"> 
<input type="button" value="Save" onclick="fnSaveInput()"> 
<input type="text" id="txt1" value="some value"> 
 
</body> 
 
</html>

Applies To

  AABBRACRONYMADDRESSAREABBIGBLOCKQUOTEBUTTONCAPTIONCENTERCITECODEDDDELDFNDIRDIVDLDTEMFONT,FORMhnHRIIMGINPUT type=buttonINPUT type=checkboxINPUT type=fileINPUT type=hiddenINPUT type=imageINPUT type=password,INPUT type=radioINPUT type=resetINPUT type=submitINPUT type=textKBDLABELLILISTINGMAPMARQUEEMENUOBJECTOLOPTION,PPLAINTEXTPREQSSAMPSELECTSMALLSPANSTRIKESTRONGSUBSUPTABLETEXTAREATTUULVARXMP

See Also

 
 

userData Behavior的更多相关文章

  1. Augmenting DOM Storage with IE's userData behavior

    http://www.javascriptkit.com/javatutors/domstorage2.shtml Augmenting DOM Storage with IE's userData ...

  2. js本地存储解决方案(localStorage与userData)

    WEB应用的快速发展,是的本地存储一些数据也成为一种重要的需求,实现的方案也有很多,最普通的就是cookie了,大家也经常都用,但是cookie的缺点是显而易见的,其他的方案比如:IE6以上的user ...

  3. IE中的userData

    之前做项目时用到了localstorage,但是考虑到浏览器存在IE8以下不兼容问题,所以来介绍以下IE中的userData. 本地存储解决方案很多,比如Flash SharedObject.Goog ...

  4. 我项目中使用userData的实例 UserData.js

    关于userData的介绍,请参见http://hi.baidu.com/kaisep/blog/item/1da9a3312d2da5a15edf0e87.htmlhttp://hi.baidu.c ...

  5. JavaScript本地存储实践(html5的localStorage和ie的userData)

    http://www.css88.com/archives/3717 JavaScript本地存储实践(html5的localStorage和ie的userData) 发表于 2011年06月11日  ...

  6. javascript 进阶篇1 正则表达式,cookie管理,userData

    首先,什么事正则表达式呢,其实引入概念很多时候并不能帮我们明白它到底是什么,所以我先简单描述下,正则表达式,其实就是一个记录字符串规则则的字符串,等我们看完这一部分,也就能明白它到底是什么了. 基本语 ...

  7. 利用userData实现客户端保存表单数据

    对于多数网页制作的朋友,实现在客户端保存在网页表单上的信息,比较多的是采用Cookie技术来实现,这些功能例如:下拉列表框选择的选项,文本框输入的数据等.事实上,我们可以利用微软DHTML默认行为中的 ...

  8. 浅析Web数据存储-Cookie、UserData、SessionStorage、WebSqlDatabase

    Cookie 它是标准的客户端浏览器状态保存方式,可能在浏览器诞生不久就有Cookie了,为什么需要Cookie 这个东东?由于HTTP协议没有状态,所以需要一个标志/存储来记录客户浏览器当前的状态, ...

  9. js本地储存userData实例

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head ...

随机推荐

  1. I NETWORK [thread1] waiting for connections on port 27017

    小技巧:mongodb安装完之后可以将安装目录的/bin添加到系统环境变量 一.问题 windows上安装完mongodb之后,设置完dbpath,一直卡在这里 二.解决办法 别关这个终端,再开个终端 ...

  2. java对象是如何创建的

    虚拟机遇到一条new指令时,首先将去检查这个指令的参数是否能在常量池中定位到一个类的符号引用,并且检查这个符合引用代表的类是否已被加载.解析和初始化过.如果没有,那必须先执行相应的类加载过程. 在类加 ...

  3. (转载)jquery实现全选、反选、获得所有选中的checkbox

    举了7个不同的checkbox状态,和大家一一分享. 1.全选 $("#btn1").click(function(){ $("input[name='checkbox' ...

  4. wpf在image控件上快速显示内存图像

    这是在博客园的第一篇文章 如果你在寻找能够快速在image控件刷新大图像(比如分辨率3000*3000的图像)的办法,尤其是想把内存中的裸数据(只有图像的数据,不包含图像头等信息)快速显示到界面,那么 ...

  5. 基于KVM的H3C云计算平台CAS运维经验

  6. VisionPro相机操作类

    在网站上看到这个,保存下来,以后用到了,再看一下.谢谢原创的分享! #region 获得相机信息方法 /// <summary> /// 公有静态方法,查找单个相机.例如“Basler” ...

  7. nodejs 几篇有用的文章

    深入浅出Node.js(三):深入Node.js的模块机制 http://www.infoq.com/cn/articles/nodejs-module-mechanism Node.js简单介绍并实 ...

  8. url的param与dict转换

    urllib.parse.urlencode urlencode from urllib import parse from urllib.request import urlopen from ur ...

  9. JavaWeb项目通过调用cmd实现备份数据库的功能

    1.别急着上车,先测试一下能否成功调用cmd,可以尝试通过cmd命令打开计算器,代码如下:     2.能成功打开计算器后,证明调用cmd的方法是没错的,现在把cmd命令字符串改成我们备份数据库的 命 ...

  10. Bing词典vs有道词典比对测试报告——体验篇之软件适应性

    联网情况: 在联网情况下,针对每一次查询,有道词典的反应速度明显比必应词典快得多.据我推测有以下两个原因: 有道词典有本地词库而必应词典更多依赖联网. 有道词典的服务器在国内而必应的在国外. 断网情况 ...