Intranet 站点上的 jQuery DataTables - getAttribute('class') 返回 null
我正在使用 dataTables 1.8.2 开发一个 Intranet Web 应用程序。
当将浏览器模式加载为 IE9 兼容视图/文档模式 IE7 时,该问题似乎仅在 IE9 中出现。发生这种情况是因为默认情况下,IE9 将此设置应用于 Intranet/本地站点。我不知道为什么。
使用fnSettings().aoData[0].nTr.getAttribute('class')
时,返回null。当文档模式设置为IE8标准或更高版本时,它返回正确的类。
有趣的是,如果我尝试使用 getAttribute('id')
,则会返回正确的 ID。
当 IE9 处于此兼容模式时,如何获取/设置 aoData 中给定行的类?
我的问题的一个例子是 http://live.datatables.net/iowob (使用 IE9 的 F12 Developer设置 IE9 兼容/IE7 标准的工具)
I am working on an intranet web application using dataTables 1.8.2.
The problem appears to occur only in IE9 when it loads the Browser Mode as IE9 Compat View / Document Mode IE7. This happens because by default, IE9 applies this setup to intranet / local sites. I have no idea why.
When using fnSettings().aoData[0].nTr.getAttribute('class')
, null is returned. When Document Mode is set to IE8 standards or above, it returns the correct class.
Interestingly, if I try using getAttribute('id')
, the correct ID is returned.
How can I get / set the class of a given row within aoData when IE9 is in this compatibility mode?
An example of my problem is at http://live.datatables.net/ijowob (Use IE9's F12 Developer tools to set IE9 Compat / IE7 Standards)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这只是 IE7 的错误。检索类名的最可靠方法是使用
elementObj.className
DOM 属性。getAttribute()
只能用于未知属性。This is just IE7 bug. The most reliable way how to retrieve class name is to use
elementObj.className
DOM attribute.getAttribute()
should be used only with unknown attributes.