html表格元素聚焦于鼠标点击
如果给一个 html 表格元素一个 tabIndex > 0 然后我可以使用 Tab 键进入该元素。如果我单击 tabIndex > 的表格元素0 那么我希望焦点会改变到该元素。但在 IE 中似乎没有这样做,而在 Firefox 和 Chome 中却可以。
如果我对 div 元素执行相同的操作,那么这确实会集中在 IE、Firefox 和 Chrome 中的鼠标单击上。
所以看来 IE 不会在鼠标单击时自动将表格元素聚焦。
谁能证实这一点吗?还有解决方法吗?我可以自己捕获鼠标单击并调用焦点,但 IE 似乎尝试在调用焦点时将元素置于屏幕中央。这在我的应用程序中看起来很糟糕。
谢谢,
阿杰
If give a html table element a tabIndex > 0 then I can tab into that element. If I click on a table element where tabIndex > 0 then I would expect the focus to change to that element. But in IE it doesn't seem to do it while in Firefox and Chome it does.
If I do the same with a div element then this does focus on mouse click in IE, Firefox and Chrome.
So it seems that IE doesn't automatically focus a table element on mouse click.
Can anyone confirm this? Also is there a workaround? I could capture the mouse click and call focus myself, but IE seems to try and center the element on the screen when focus is called. This looks bad in my app.
Thanks,
AJ
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看这篇文章: http://nemisj.com/focusable/
基本上,浏览器都以不同的方式实现焦点传统上“不可聚焦”的元素。对于 IE,您可以改用单击事件(使用条件代码和浏览器检测),或实施链接文章中建议的解决方法之一。
Check out this article: http://nemisj.com/focusable/
Basically, the browsers all differently implement focus on traditionally "non-focusable" elements. With IE, you can use a click event instead (using conditional code and browser detection), or implement one of the workarounds suggested in the linked article.