【问题标题】:ARIA attributes in IE10IE10 中的 ARIA 属性
【发布时间】:2012-11-18 15:45:25
【问题描述】:

我正在尝试使用 jQuery 在元素上设置 aria-autocomplete 属性。但是,当 IE10IE5 Quirks 模式IE7 标准模式 下运行时,它会产生 Member not found 错误。

<input type="textbox" id="test" />​
$('#test').attr({"aria-autocomplete": "list"});​

请参阅此jsFiddle 以获取演示。

我已经尝试过这里定义的各种其他 ARIA 属性:

HTML 5: The Markup Language (ARIA Edition)

有些会产生相同的错误,有些则不会。

我无法在 IE9 中重现错误。

这是 IE10 的错误吗? jQuery?还是有其他我不理解的原因?

【问题讨论】:

  • jQuery 不支持 quirks 模式。我不确定 IE10 中的 IE7 标准模式。我得调查一下。

标签: jquery internet-explorer internet-explorer-10 wai-aria


【解决方案1】:

波兹,

这是 IE10 浏览器在兼容模式下的一个已知错误。请对此错误票投赞成票,以增加修复它的可能性。 https://connect.microsoft.com/IE/feedback/details/774078票是jQuery团队提交的。

您是否在真正的 IE7 中尝试过您的代码示例?我用浏览器堆栈(WinXP/IE7)尝试了你的 jsFiddle,并且示例工作没有错误。

如果您使用兼容模式来模拟测试 IE7,那么好消息是使用原生 IE7 可以正常工作。坏消息是 IE10 兼容模式存在一个错误。

【讨论】:

  • 谢谢以利亚。我赞成这个错误。我只使用 IE10 开发工具测试了 IE7,所以应该没问题。
  • @Elijah_Manor - 该链接已损坏。您介意提供另一个,以便我可以投票吗??谢谢
  • @johntrepreneur - 链接没有损坏。如果您看不到它,则需要在该站点注册并加入 IE 反馈计划。 jQuery bug 上的 cmets 让您看起来只需要注册。
  • 链接对我不起作用:找不到您请求的内容或您无权查看。
  • Microsoft 已推迟对此问题的任何修复。由于 IE-11 现已推出,它可能会被永远推迟......
【解决方案2】:

这就是我的解决方案。在您使用的 Jquery 版本中,在我的 cas (jquery-1.7.2.js) 中,第 2764 行周围有一段是这样的:

// Use this for any attribute in IE6/7
// This fixes almost every IE6/7 issue
nodeHook = jQuery.valHooks.button = {
    get: function( elem, name ) {
        var ret;
        ret = elem.getAttributeNode( name );
        return ret && ( fixSpecified[ name ] ? ret.nodeValue !== "" : ret.specified ) ?
            ret.nodeValue :
            undefined;
    },
    set: function( elem, value, name ) {
        // Set the existing or create a new attribute node
        var ret = elem.getAttributeNode( name );
        if ( !ret ) {
            ret = document.createAttribute( name );
            elem.setAttributeNode( ret );
        }
        return ( ret.nodeValue = value + "" );
    }
};

根据https://bugs.jquery.com/ticket/12577的说法,是IE10在IE7模式下的兼容性问题。解决方法是改变set函数中的返回变量:

 return ( ret.nodeValue = value + "" );
//for:
elem.setAttribute(name, value + ""); 
return (ret.value);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-29
    • 1970-01-01
    • 1970-01-01
    • 2018-10-02
    相关资源
    最近更新 更多