Stop table & td elements out of focus

In IE, it seems that the table and td elements will automatically gain focus on the mouse click.

Taken from

http://msdn.microsoft.com/en-us/library/ms534654%28VS.85%29.aspx

The following items may have focus by default, but are not tabbed stops. These elements can be set as tabs by setting the tabIndex property to a positive integer. applet, div, frameSet, span, table, etc.

I set tabIndex for the table element, but when I clicked one of the td elements of this table, the table seems to lose focus! This seems crazy to me; it does not happen in Firefox or Chrome.

Has anyone else encountered this, and if so, will it still stop?

Thanks,

Aj

+4
source share
1 answer

The following items may have focus by default, but are not tabbed stops. These elements can be set as tabs by setting the tabIndex property to a positive integer. applet, div, frameSet, span, table, etc.

td gets the focus and therefore removes it from the table. I could not find a convenient link, but if the memory is served, IE is the only browser that allows td to have focus without specifying the tabindex attribute for td.

<table onclick="this.focus()" tabindex="1"> 

In any case, the above works in all the browsers mentioned, but it is not very useful if something in the table should get focus.

0
source

All Articles