I came across a very strange behaviour on Chrome which seems like a bug to me: when you click a link, the link does not receive the focus. Worse, the body takes the focus instead.
This behaviour can be observed here: / (see code sample here
)
Is this a bug? Is this standard behaviour? Is there any workaround to make the links receive the focus on mouse down, like on the other browsers?
I came across a very strange behaviour on Chrome which seems like a bug to me: when you click a link, the link does not receive the focus. Worse, the body takes the focus instead.
This behaviour can be observed here: http://jsfiddle/YfbR7/4/ (see code sample here
)
Is this a bug? Is this standard behaviour? Is there any workaround to make the links receive the focus on mouse down, like on the other browsers?
Share Improve this question asked Aug 23, 2013 at 9:47 Gyum FoxGyum Fox 3,6272 gold badges46 silver badges76 bronze badges 1- The same behaviour also applies to checkboxes, see question here: stackoverflow./questions/18400190/… – Gyum Fox Commented Aug 23, 2013 at 10:11
3 Answers
Reset to default 7Add tab index to anchor tag it should work, it's not a bug its a web kit thingy.
<a href="#" tabindex="1">Click me</a>
A link should always natively receive focus. If your link does not have a href
attribute it won't (not sure the use case of a link without a href though!).
In addition to the accepted answer:
Since setting tabindex
to 1
would change the TAB behavior, I remend setting it to -1
instead: it won't break the TAB navigation and will still enable it from being focused.
<a href="#" tabindex="-1">Example</a>
By the way, here's a very nice article regarding these concerns.
Note: the same thing happened with me, but just on Safari: probably Chrome has already that issue fixed.