AJ.
AJ.

Reputation: 11240

html table element focus on mouse click

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

Upvotes: 0

Views: 1110

Answers (1)

Chris Baker
Chris Baker

Reputation: 50592

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.

Upvotes: 1

Related Questions