Internet explorer:用户数据行为的官方状态?

时间:2021-11-15 17:12:27

I've been having trouble with the userData behavior in IE9, which I use when an IE version that doesn't support the Web Storage spec is encountered.

我在IE9中遇到了用户数据行为的问题,当遇到不支持Web存储规范的IE版本时,我就会使用它。

Specifically, values don't seem to be saved when the .save() function is executed (in fact, there isn't even a userData folder in C:\Users\USERNAME\AppData\Roaming\Microsoft\Internet Explorer\UserData , nor is it created upon executing the .save()).

具体来说,价值观似乎不得救的时候.save()函数执行(事实上,甚至没有一个用户数据文件夹在C:\Users\USERNAME\AppData\Roaming\Microsoft\Internet Explorer \用户数据,也不是在执行创建.save())。

I did some research and the consensus, from a handful of comments on various sites, is that it seems to be disabled in IE9.

我做了一些研究,从不同网站上的一些评论中得出的共识是,它似乎在IE9中被禁用了。

Is there some sort of official statement expressing this? If so, is there a way to test whether a given IE version supports it (without browser sniffing)?

有没有什么官方声明来表达这一点?如果是这样,是否有一种方法来测试给定的IE版本是否支持它(没有浏览器嗅探)?

1 个解决方案

#1


6  

After some research I seem to have (for the most part) found the answers to my questions.

经过一些研究,我似乎(大部分)找到了我问题的答案。

Is there some sort of official statement expressing this ("this" meaning that userData is no longer supported in IE9)?

是否有某种官方声明来表达这个(“this”意味着在IE9中不再支持用户数据)?

Since I could find no official statement confirming the discontinuation of support for this particular behavior in IE9, comments and complaints across the net will have to suffice: the userData behavior is not supported in IE9. Additionally, no behaviors and HTCs are supported in IE10.

由于我没有找到任何官方声明来证实对IE9中这种特殊行为的支持停止,网络上的评论和抱怨就足够了:用户数据行为在IE9中是不受支持的。此外,IE10不支持任何行为和HTCs。

Is there a way to test whether a given IE version supports it (the userData behavior) (without browser sniffing)?

是否有一种方法可以测试给定的IE版本是否支持它(用户数据行为)(没有浏览器嗅探)?

For IE10 and the very early versions of IE that don't support userData, one can check for the existence of the addBehavior() member function on the element that the behavior has been attached to:

对于IE10和早期不支持用户数据的IE版本,可以检查行为所附加的元素上是否存在addBehavior()成员函数:

//Assuming "element" has had the userData behavior associated with it through CSS
if(element.addBehavior)

Handling IE9 is a little more tricky, since userData behavior related methods are present and do not throw exceptions when correctly used.

处理IE9有点棘手,因为用户数据行为相关的方法是存在的,正确使用时不要抛出异常。

Luckily, we can take advantage of the relationship between the data storage mechanism and the XMLDocument member that each element with the userData behavior receives. Since this particular member represents the file to be stored to disk when save() is called, element.XMLDocument.xml is supposed to be updated with each call to element.addAttribute(key, value). If it is not, then we can assume that userData is not supported:

幸运的是,我们可以利用数据存储机制和XMLDocument成员之间的关系,每个元素都具有userData行为。因为这个特定的成员表示在调用save()时要存储到磁盘的文件element.XMLDocument。xml应该在每次调用元素时更新。addAttribute(关键字,值)。如果不支持,则假设不支持userData:

//Assuming "element" has had the userData behavior associated with it through CSS
if(element.addBehavior)
{
    element.addAttribute("test", "");

    //If the to-be-saved XML was updated with the attribute we just added
    if(element.XMLDocument.xml.indexOf("test") !== -1) 
    {
        //userData behavior is supported
    }
    else
    {
        //userData behavior is not supported
    } 
}

An official statement from MS confirming this drop of support would still be appreciated, as well as a method for determining full userData behavior support without adding a dummy attribute. If you come across either of these, feel free to post them.

MS的一份官方声明确认了这一下降的支持,以及在不添加假属性的情况下确定完整的userData行为支持的方法仍然值得赞赏。如果您遇到了其中任何一个,请随意发布它们。

#1


6  

After some research I seem to have (for the most part) found the answers to my questions.

经过一些研究,我似乎(大部分)找到了我问题的答案。

Is there some sort of official statement expressing this ("this" meaning that userData is no longer supported in IE9)?

是否有某种官方声明来表达这个(“this”意味着在IE9中不再支持用户数据)?

Since I could find no official statement confirming the discontinuation of support for this particular behavior in IE9, comments and complaints across the net will have to suffice: the userData behavior is not supported in IE9. Additionally, no behaviors and HTCs are supported in IE10.

由于我没有找到任何官方声明来证实对IE9中这种特殊行为的支持停止,网络上的评论和抱怨就足够了:用户数据行为在IE9中是不受支持的。此外,IE10不支持任何行为和HTCs。

Is there a way to test whether a given IE version supports it (the userData behavior) (without browser sniffing)?

是否有一种方法可以测试给定的IE版本是否支持它(用户数据行为)(没有浏览器嗅探)?

For IE10 and the very early versions of IE that don't support userData, one can check for the existence of the addBehavior() member function on the element that the behavior has been attached to:

对于IE10和早期不支持用户数据的IE版本,可以检查行为所附加的元素上是否存在addBehavior()成员函数:

//Assuming "element" has had the userData behavior associated with it through CSS
if(element.addBehavior)

Handling IE9 is a little more tricky, since userData behavior related methods are present and do not throw exceptions when correctly used.

处理IE9有点棘手,因为用户数据行为相关的方法是存在的,正确使用时不要抛出异常。

Luckily, we can take advantage of the relationship between the data storage mechanism and the XMLDocument member that each element with the userData behavior receives. Since this particular member represents the file to be stored to disk when save() is called, element.XMLDocument.xml is supposed to be updated with each call to element.addAttribute(key, value). If it is not, then we can assume that userData is not supported:

幸运的是,我们可以利用数据存储机制和XMLDocument成员之间的关系,每个元素都具有userData行为。因为这个特定的成员表示在调用save()时要存储到磁盘的文件element.XMLDocument。xml应该在每次调用元素时更新。addAttribute(关键字,值)。如果不支持,则假设不支持userData:

//Assuming "element" has had the userData behavior associated with it through CSS
if(element.addBehavior)
{
    element.addAttribute("test", "");

    //If the to-be-saved XML was updated with the attribute we just added
    if(element.XMLDocument.xml.indexOf("test") !== -1) 
    {
        //userData behavior is supported
    }
    else
    {
        //userData behavior is not supported
    } 
}

An official statement from MS confirming this drop of support would still be appreciated, as well as a method for determining full userData behavior support without adding a dummy attribute. If you come across either of these, feel free to post them.

MS的一份官方声明确认了这一下降的支持,以及在不添加假属性的情况下确定完整的userData行为支持的方法仍然值得赞赏。如果您遇到了其中任何一个,请随意发布它们。