I follow this page to make a "Skip Navigation" link, however it is not working in Chrome (5.0.375.127).
When I tab and enter the link, it scroll to the content, but when I continue to tab, it starts from the top but not start from the content.
That page's skip "Skip Navigation" link is not working in Chrome either.
Is it a bug of Chrome? Any workaround?
Here is my workaround. It enables keyboard skip navigation link to any element id on its page.
The link's
onclick
event handler is here.The following is my assumption.
a
link withhref
attribute could be the proper destination of anchor link for keyboard navigation.href
attribute froma
link with focus, browsers will still remember the focus position for keyboard navigation while it will not show you the focus mark on the screen any more.I wrote it for popup page skip navigation which isn't likely to be scrolled. I hope it will works even for screen readers.
I get it. The target should be a tag that can be focused, like a link, if not, which is my case a div, should set tabindex of the target as -1.
My jQuery solution, with ScrollTo plug-in, is:
I can confirm that Andy Li's answer works, but I didn't need the scrollTo stuff. I also added in a hook so that if you are loading a page with an anchor link already applied, the appropriate focus would be given.
My version was:
I know this is an old question, but I finally stumbled across it today after searching for hours. I still haven't found a non-js solution to this, and though the issue is marked as fixed in Chrome, it still exhibits the same behavior. For a lack of anything else, I used jQuery. Rather than an inline script, I used an unobtrusive event listener.
The HTML:
The jQuery:
I also hide the link unless it receives focus from the keyboard. That way only keyboard users and screen readers will ever know the link is there. Using CSS3, you can ensure that it becomes briefly visible if a user tabs rapidly past it.
The CSS:
For a demonstration, you can view the fiddle. If anyone has a way around the use of javascript, I would love to hear it. I don't think a solution is truly accessible if it requires js.
There is a known bug in Chrome (Webkit) that prevents you from scrolling twice to an anchor. So if you openen #anchor previously, scrolled up, and clicked again on a link reffering to #anchor, it won't work.
See: http://code.google.com/p/chromium/issues/detail?id=42511
I haven't tried it yet, but what about using javascript to clear the hash first? Like this:
Tested the following in Chrome, it works:
I believe it is most correct to attribute this to chrome bug #37221 as per Knu in the answer to Skip links not working in Chrome.
I don't agree that Javascript workarounds are appropriate for the long term.