IE userData行为在Windows Phone 7的IE中不起作用

时间:2011-06-24 13:06:43

标签: javascript internet-explorer windows-phone-7

我无法在WP7上的IE中使用userData行为。 (注意:这是指WP7中IE的原始IE7版本;而不是随芒果更新提供的IE9版本。)有没有人知道这是一个错误,还是行为不是首先实现或启用?更好的是一种解决方法......我还没找到。

最小测试用例:

<!doctype html>
<html>
    <head>
        <style>
            #store {
                behavior:url('#default#userData');
                display:none;
            }
        </style>
    </head>
    <body>
        <div id="store"></div>
        <h1>IE userData behavior test
        <script>
            var storageElement = document.getElementById("store");
            storageElement.setAttribute('monkey', 'fez');
            try {
                storageElement.save('storagetest');
                alert('Saved some data with the storage Element!'); // IE 7,8,9
            } catch(e) {
                alert("Failed to save data with the storage Element."); // IE on WP7
            }
        </script>
    </body>
</html>

(http://jsbin.com/urepoq/edit)

1 个答案:

答案 0 :(得分:2)

我的第一个想法是尝试-ms-前缀,就像在-ms-behavior中一样。但是,我很确定Windows Phone 7上的IE7 / IE8混合浏览器不支持任何行为。我无法找到这方面的确切证据,除了我尝试过的少数不起作用以及根本不支持VML(也实现为行为)的知识。


正如OP所发现的那样,Designing Web Sites for Mobile Phones的最后一部分陈述如下:

  

不支持的插件

     

与桌面浏览器不同,Internet Explorer Mobile不允许最终用户下载或安装第三方插件,如ActiveX控件。网页不应该提示用户下载插件。 此外,Internet Explorer Mobile不支持DHTML或二进制行为。

所以,看起来你运气不好。