Read Damon Muma on this. He proposes the following jQuery solution (inspired by Thompson, fixed by me):
// Apply focus properly when accessing internal links with keyboard in WebKit browsers.
$("a[href^='#']").not("a[href='#']").click(function() {
$("#"+$(this).attr("href").slice(1)+"").focus();
});
I don’t like to use jQuery however, and have been trying to port it to plain Javascript.
- Pilot version. (d385d2)
tabindex
now using-1
instead of0
, as per Smith, added this README, and added UNLICENCE. (c194df)- Updates to the README. (0fce31)
- Added file extension to README. Oops. (a31368)
- Last change to README. I hope. (7d175b)
- Added a clause to check for pre-existing
tabindex
values. (a39c9b) - Added support for named anchors. The
name
attribute is obsolete and is only checked for backwards compatibility. (0ab22c) - Current: No more errors on empty fragments (
#
) or undefined elements (#thisIDisnotused
).
Hi! Would it be possible to extend this method so that links followed from the longdesc attribute or the cite attribute would also change focus? For a Webkit browser that allows you to open @longdesc URLs and @cite URLs, see iCab. http://www.icab.de Longdesc attribute URLs and cite attribute URL are, in iCab, opened via a contextual menu. I have a test page here: http://malform.no/testing/a-demo-of/longdesc-with-hidden-iframe/